type
Post
status
Published
date
Feb 24, 2025
slug
2025/02/24/overview-xenomai-3
summary
tags
Linux
rt-kernel
category
Linux
created days
new update day
icon
password
Created_time
Feb 24, 2025 03:22 AM
Last edited time
Mar 1, 2025 01:50 AM
Xenomai 3 is a real-time framework which can run seamlessly side-by-side Linux as a dual kernel system, or natively over mainline Linux kernels. In the latter case, the mainline kernel can be supplemented by the PREEMPT-RT patch to meet stricter response time requirements than standard kernel preemption would bring.
Xenomai 3是一个实时框架,它可以与Linux无缝并行运行作为双内核系统,或者直接运行在主线Linux内核之上。在后一种情况下,可以通过PREEMPT-RT补丁来增强主线内核,以满足比标准内核抢占更严格的响应时间要求。
One of the two available real-time cores is selected at build time. The dual kernel core is codenamed Cobalt, the native Linux implementation is called Mercury.
两个可用的实时核心之一在构建时选择。双内核核心的代号为Cobalt,原生Linux实现称为Mercury。
If you are looking for detailed information about installing the legacy Xenomai 2.x series, please refer to this document instead. Please note that Xenomai 2.x is discontinued and not maintained anymore.
如果您正在寻找有关安装传统Xenomai 2.x系列的详细信息,请参考此文档。请注意,Xenomai 2.x已停止使用且不再维护。
How does Xenomai 3 deliver real-time?
Xenomai 3如何实现实时性?
There are two options:
有两种选择:
- By supplementing Linux with a real-time core running side-by-side with it. This small extension named Cobalt is built into the Linux kernel, dealing with all time-critical activities, such as handling interrupts, and scheduling real-time threads. The Cobalt core has higher priority over the native kernel activities.
- 通过在 Linux 旁边运行一个实时核心来增强 Linux。这个名为 Cobalt 的小型扩展被构建到Linux内核中,处理所有时间关键的活动,如处理中断和调度实时线程。Cobalt核心具有比原生内核活动更高的优先级。
In this dual kernel configuration, all the RTOS APIs Xenomai 3 provides interface with the Cobalt core, and only those APIs are deemed real-time capable, including the subset of POSIX 1003.1c services implemented by Xenomai 3 (aka libcobalt).
在这种双内核 配置中,Xenomai 3提供的所有RTOS API都与 Cobalt 核心进行接口,只有这些API被认为具有实时能力,包括Xenomai 3实现的POSIX 1003.1c服务子集(又称libcobalt)。

Cobalt is an evolution of the legacy Xenomai 2 architecture.
Cobalt是Xenomai 2架构的一个演进版本。
- By relying on the real-time capabilities of the native Linux kernel, forming the Mercury core. Often, applications will require the PREEMPT-RT extension to be enabled in the target kernel, for delivering real-time services.
- 通过依赖原生Linux内核的实时能力,形成Mercury核心。通常,应用程序需要在目标内核中启用PREEMPT-RT扩展,以提供实时服务。
However, this is not mandatory, it depends on the application requirements with respect to responsiveness and maximum jitter; some may even tolerate a certain percentage of deadline misses.
然而,这并非强制要求,这取决于应用程序对响应性和最大抖动的要求;有些应用程序甚至可以容忍一定比例的截止期限错过。
In this single kernel configuration, all the non-POSIX RTOS APIs Xenomai 3 provides are accurately emulated over the native threading library (preferably NPTL, but also supports linuxthreads for legacy setups).
在这种单内核 配置中,Xenomai 3 提供的所有非 POSIX RTOS API 都通过原生线程库(优先使用NPTL,但也支持用于传统设置的 linuxthreads)进行精确模拟。

Xenomai 3 supports both the single and dual kernel configurations. The discontinued Xenomai 2 architecture only supported the dual kernel configuration.
Xenomai 3 支持单内核和双内核配置。 已停产的 Xenomai 2 架构只支持双内核配置。
Supported hardware
支持的硬件
Xenomai 3 is supported on a variety of hardware. The ports we know about are listed here.
Xenomai 3支持多种硬件。我们已知的移植版本可在此处查看。
Xenomai 3 license terms
All Xenomai 3 code running in kernel space is licensed under the terms of the Linux kernel license, i.e. GPL v2. Xenomai libraries linked to applications are licensed under the terms of the LGPL v2.1. For information regarding a particular software component, you should look at the COPYING file available in the directory containing the relevant source code.
所有在内核空间运行的Xenomai 3代码都遵循Linux内核许可证条款,即GPL v2。与应用程序链接的Xenomai库遵循LGPL v2.1许可证条款。关于特定软件组件的信息,您应该查看包含相关源代码的目录中的COPYING文件。
Preparation checklist
准备清单
Single or dual kernel configuration?
单内核还是双内核配置?
Assuming you know the target SoC and the application requirements with respect to real-time guarantees, you should define which of the single or dual kernel configurations best fits your needs. The following hints may help:
假设您已经了解目标SoC和应用程序对实时性保证的要求,您应该确定单内核或双内核配置哪个最适合您的需求。以下提示可能会有帮助:
- Does your application actually have real-time requirements, and how stringent are they? If migrating an application from an embedded RTOS to a Linux-based platform, the question may stand because unlike legacy RTOSes, Linux sees embedded and real-time characteristics as orthogonal issues. Some migrated applications may even be fine with only emulating the original RTOS API over a regular kernel and standard preemption (CONFIG_PREEMPT). Those may benefit from Xenomai 3 in single kernel configuration.
- 您的应用程序是否真的有实时性要求,这些要求有多严格?如果要将应用程序从嵌入式 RTOS迁移到基于Linux的平台,这个问题就很重要,因为与传统RTOS不同,Linux将嵌入式和实时性特征视为正交问题。某些迁移的应用程序甚至可以仅通过在常规内核和标准抢占(CONFIG_PREEMPT)上模拟原始RTOS API来满足需求。这些应用程序可能适合使用Xenomai 3的单内核配置。
- For stringent real-time requirements, you should consider the availability of the hard real-time support for your target SoC architecture and Linux kernel version.
- Hardware support for Xenomai 3 in dual kernel configuration can be viewed here. This approach is based on a kernel software layer which introduces a mechanism for diverting all critical events to a dual kernel extension core, coupled to the host Linux kernel. This mechanism called Dovetail implements an Interrupt pipeline.
- For a single kernel configuration, the list of target architectures supporting the full preemption features (aka PREEMPT-RT) is available here.
- How many CPU cores will be involved in real-time operations?
- in a dual kernel configuration, the Xenomai 3 Cobalt core normally benefits from its simpler locking scheme when dealing with real-time activities concurrently on not more than four CPU cores.
- Beyond four CPU cores running real-time activities, SMP scalability will be better with a single kernel configuration.
对于严格的实时性要求,您应该考虑目标SoC架构和Linux内核版本是否支持硬实时。
双内核配置下Xenomai 3的硬件支持可以在这里查看。这种方法基于一个内核软件层,该层引入了一种机制,将所有关键事件转移到与主机Linux内核耦合的双内核扩展核心。这种称为Dovetail的机制实现了一个中断流水线。
对于单内核配置,支持完全抢占特性(即PREEMPT-RT)的目标架构列表可在这里找到。
有多少CPU核心将参与实时操作?
在双内核配置中,当同时在不超过四个CPU核心上处理实时活动时,Xenomai 3 Cobalt核心通常会受益于其更简单的锁定方案。
对于超过四个CPU核心运行实时活动的情况,单内核配置的SMP可扩展性会更好。
The key issue is with the number of CPU cores actually running real-time threads and receiving interrupts from real-time sources, not with the overall number of cores on line on the target hardware. Because the Cobalt cocore does not share any lock with the regular Linux kernel when dealing with real-time activities, a 16-way server pinning such activities on not more than four of the available cores would still deliver good performances in a Cobalt-based dual kernel configuration.
关键问题在于实际运行实时线程并接收来自实时源中断的CPU核心数量,而不是目标硬件上在线的总核心数量。因为Cobalt协处理器在处理实时活动时不与常规Linux内核共享任何锁,所以一个16路服务器将这些活动固定在不超过四个可用核心上时,在基于Cobalt的双内核配置中仍然能够提供良好的性能。
If you need a SMP scalable real-time core, then you may want to consider Xenomai 4 instead. The EVL core underlying Xenomai 4 implements a fine-grained locking model which does not suffer the scalability issue of its predecessor.
如果您需要一个可扩展的SMP实时核心,那么您可以考虑使用Xenomai 4。Xenomai 4底层的EVL核心实现了细粒度的锁定模型,不会受到其前身的可扩展性问题的影响。
- Is any of those dual kernel pros critical to your case?
- porting the Cobalt core to a new architecture is fairly simple.
- it is decoupled from the development cycle of the mainline Linux kernel, thus allowing to pick the desired (or required) kernel version more freely.
- it can simplify the worst-case analysis and keeps the results valid over update cycles of the mainline Linux kernel which hosts it.
- it allows to fine-tune the non-real-time part for throughput without negative impact on the real-time job.
- it does not require any tuning of the regular Linux system to guarantee short and bounded latencies for the real-time job.
- 以下这些双内核的优势对您的情况是否至关重要?
- 将Cobalt核心移植到新架构相对简单。
- 它与主线Linux内核的开发周期是解耦的,因此可以更自由地选择所需(或要求的)内核版本。
- 它可以简化最坏情况分析,并使结果在托管它的主线Linux内核更新周期中保持有效。
- 它允许对非实时部分进行吞吐量优化,而不会对实时任务产生负面影响。
- 它不需要对常规Linux系统进行任何调优就能保证实时任务的短暂且有界的延迟。
- Is any of those single kernel pros critical to your case?
- the stock kernel drivers can be reused by real-time applications with no change (provided they don't create latency issues due to an unfortunate implementation). On the other hand, drivers need to be specifically implemented for running over a dual kernel configuration, i.e. over the in-kernel RTDM interface.
- the programming model may be simpler than with a dual kernel configuration, since the kernel is deemed to enforce real-time behavior globally. This said, cautious application design and implementation must be a common rule regardless of the underlying real-time technology, as not all available services may be suited for real-time usage.
- all standard utilities for monitoring the system operations can report about the real-time activities out of the box. On the other hand, a dual kernel system has to adapt such tools specifically for this purpose.
以下这些单内核的优势对您的情况是否至关重要?
- 实时应用程序可以直接复用现成的内核驱动程序而无需修改(前提是这些驱动程序的实现不会造成延迟问题)。另一方面,在双内核配置下运行的驱动程序需要专门实现,即通过内核中的RTDM接口实现。
- 由于内核被设计为全局强制执行实时行为,其编程模型可能比双内核配置更简单。话虽如此,无论底层采用何种实时技术,谨慎的应用程序设计和实现都必须是通用规则,因为并非所有可用服务都适合实时使用。
- 所有用于监控系统操作的标准工具都可以直接报告实时活动。另一方面,双内核系统必须专门适配这些工具以实现此目的。
Do you need non-POSIX real-time APIs?
您是否需要非POSIX实时API?
Porting legacy non-POSIX applications to POSIX may not be the best option. Although there may be similarities, the semantics of traditional RTOS APIs may differ significantly from POSIX in many cases, which often makes the migration process quite painful and error-prone.
将传统的非POSIX应用程序移植到POSIX可能不是最佳选择。尽管可能存在一些相似之处,但传统RTOS API的语义在许多情况下可能与POSIX有显著差异,这往往使迁移过程变得痛苦且容易出错。
Xenomai 3 ships with emulators of traditional RTOS APIs, like VxWorks™ and pSOS™, both available in single and dual kernel configurations. Xenomai 3 aims at accurately mimicking the original services with low overhead.
Xenomai 3提供传统RTOS API的模拟器,如VxWorks™和pSOS™,这些模拟器在单内核和双内核配置中都可用。Xenomai 3旨在以低开销准确模拟原始服务。
However, maybe Xenomai 3 does not provide an emulator yet for the API you are looking for, or some services are missing from the existing emulators, in which case you should consider raising the topic on the e-mail discussion list. Xenomai 3 is based on generic building blocks for implementing RTOS APIs, so extending it is a documented option.
然而,Xenomai 3可能尚未为您所需的API提供模拟器,或现有模拟器中缺少某些服务,在这种情况下,您应考虑在邮件讨论列表中提出该话题。Xenomai 3基于通用构建块来实现RTOS API,因此扩展它是一个有文档记录的选项。
Using GIT
The Xenomai project uses GIT for managing the source code repositories. There is no shortage of GIT crash courses, references, howtos, tips and comprehensive documentation available from the Internet. For the sake of conciseness, we will only mention two documentation hubs from which you should be able to find your way:
Xenomai项目使用GIT来管理源代码仓库。互联网上有大量的GIT速成教程、参考资料、操作指南、技巧和综合文档。为了简洁起见,我们仅提供两个文档中心,您可以从这里开始:
- GIT项目文档中心
- GIT文档维基
In addition, let's mention a simple tutorial for bootstrapping with GIT and day-to-day usage:
此外,这里有一个关于GIT入门和日常使用的简单教程:
Building Xenomai 3 from sources
从源代码构建Xenomai 3
This document contains instructions for building and installing Xenomai 3.x.
本文档包含了构建和安装Xenomai 3.x的说明。
Xenomai-3 development tree
Xenomai-3开发树
The Xenomai 3 development takes place in the xenomai repository of this Gitlab instance operated by Denx Software Engineering , a long-time contributor to the Xenomai project.
- the master branch tracks the development HEAD toward the next major release. This branch is never rebased.
- the next branch tracks the latest commits pending merge into the master branch, it contains the most bleeding edge work. This branch may be rebased until it gets merged into the master branch eventually.
- stable-* branches track updates to stable releases, such as stable-3.2.x which is the maintenance branch for the v3.2 major release. Those branches are never rebased.
- master 分支跟踪指向下一个主要版本的开发HEAD。该分支永远不会被重基(rebase)。
- next 分支跟踪等待合并到master分支的最新提交,它包含最前沿的工作。在最终合并到master分支之前,该分支可能会被重基。
- stable-* 分支跟踪稳定版本的更新,例如stable-3.2.x是v3.2主要版本的维护分支。这些分支永远不会被重基。
If something goes wrong
如果出现问题
First and foremost, please make sure to have a look at the troubleshooting guide .
首先,请务必查看故障排除指南 。
If running any release from the discontinued Xenomai 2 series, or a Xenomai 3 release using the Cobalt real-time core, then you are running a dual kernel configuration. Xenomai 3 over the Mercury core stands for a single kernel configuration.
如果运行的是已停产的 Xenomai 2 系列或使用 Cobalt 实时内核的 Xenomai 3 版本,则属于双内核配置。 使用 Mercury 内核的 Xenomai 3 代表单内核配置。
If still out of luck, and if your favorite Internet search engine did not help finding a similar/same problem already solved for another user, then you should try raising the issue on the main e-mail discussion list .
如果您仍然不走运,而且您最喜欢的互联网搜索引擎也无法帮助您找到已为其他用户解决的类似/相同问题,那么您可以尝试在主电子邮件讨论列表中提出问题。
To maximize your chances of receiving quick and accurate responses to your request for help, you really want to follow these recommendations .
为了最大限度地提高您的求助请求得到快速准确回复的几率,您一定要遵循以下建议。
Embedded Linux distributions & Xenomai
嵌入式 Linux 发行版和 Xenomai
The Yocto-based Embedded Linux Development Kit (aka ELDK) includes pre-built GNU cross-development tools and bootable root file systems for a variety of ARM™, PowerPC™ and MIPS™ embedded target systems. It also ships with a pre-built stable Xenomai release.
基于 Yocto 的嵌入式 Linux 开发工具包(又称 ELDK)包括预构建的 GNU 交叉开发工具和可引导根文件系统,适用于各种 ARM™、PowerPC™ 和 MIPS™ 嵌入式目标系统。 它还预装了稳定的 Xenomai 版本。
欢迎加入“喵星计算机技术研究院”,原创技术文章第一时间推送。

- 作者:tangcuyu
- 链接:https://expoli.tech/articles/2025/02/24/overview-xenomai-3
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
相关文章