Xenomai 三 和 PREEMPT_RT 相比有什么好处

Xenomai 3 和 PREEMPT_RT 相比有什么好处

Q: 我能在我的开发板PREEMPT_RT内核的环境上直接运行POSIX的应用, 那用Xenomai3 的理由是什么呢?

A:如果你的应用已经完全是POSIX,并且性能也满足的话,那并没有什么理由用Xenomai3.但是你可能会基于以下两点考虑采用Xenomai3.

- 你想移植遗留的嵌入式应用到Linux上而不用修改API. 比如说,你不想在POSIX接口上重写API, 这时候Xenomai就能发挥它的用场.因为它通过一个共通的实时性来支持多个编程接口,包括传统的RTOS API, Xenomai3也将在基于PREEMPT_RT的系统上支持这些API.

- 你的目标板的性能不足,或/并且你想要你的实时任务给系统追加最小的负载. 这就是双内核机制优于原生的抢占系统的一个地方. 后者的情况下,所有的Linux系统必须执行内部代码(如优先级继承,中断线程化)来防止实时处理被延迟, 但是在双内核系统里, 并没有这种必要,因为实时内核是区别于Linux内核独立执行的,故而,通常的Linux动作并不会对实时动作有影响,它甚至都不需要知道实时内核.


总而言之, 对这类问题并没有一个统一的答案:它实际上依赖于你对性能的要求和你的开发板的性能. 这是一个case-by-case的东西. 只是说"我们可以在最坏情况下达到X微秒"却不指明板子的性能并没有什么意义.

Xenomai 3 FAQ

Q: I can run POSIX based applications directly over a PREEMPT_RT kernel on my target system, so what is the point of running Xenomai 3 there?

A: If your application is already fully POSIXish, and the performances requirements are met, then there is likely no point. However, you may want to consider Xenomai 3 in two other situations:

  • you want to port a legacy embedded application to Linux without having to switch APIs, i.e. you don't want to rewrite it on top of the POSIX interface. Xenomai may help in this case, since it supports multiple programming interfaces over a common real-time layer, including emulators of traditional RTOS APIs. Xenomai 3 will make those APIs available to a PREEMPT_RT based system as well.
  • the target hardware platform has limited horsepower, and/or you want the real-time job to put the smallest possible overhead on your system. This is where dual kernels are usually better than a native preemption system. With the latter, all parts of the Linux system have to run internal code that prevents real-time activities from being delayed in an unacceptable manner (e.g. priority inheritance mechanism, threaded IRQ handlers). In a dual kernel system, there is no need for this, since the real-time co-kernel runs separately from the normal Linux kernel. Therefore, regular Linux activity is not charged for real-time activity, it does not even have to know about it.

In short, there cannot be any pre-canned answer to such a question: it really depends on your performance requirements, and your target hardware capabilities. This has to be evaluated on a case-by-case basis. Telling the world about "we can achieve X microseconds worst-case latency" without specifying the characteristics of the target platform would make no sense. 

原文参考:http://www.xenomai.org/index.php/Xenomai:Roadmap#Xenomai_3_FAQ