Inside Real-Time Linux

2023-05-16

本文转载于:https://www.linux.com/news/event/elce/2017/2/inside-real-time-linux

Jan Altenberg
Real-time Linux has come a long way in the past decade. Jan Altenberg of Linutronix provides an overview of the topic and offers new RTL performance benchmarks in this video from ELC Europe.
The Linux Foundation

Real-time Linux (RTL), a form of mainline Linux enabled with PREEMPT_RT, has come a long way in the past decade. Some 80 percent of the deterministic PREEMPT_RT patch is now available in the mainline kernel itself. Yet, backers of the strongest alternative to the single-kernel RTL on Linux -- the dual-kernel Xenomai -- continue to claim a vast superiority in reduced latency. In an Embedded Linux Conference Europe presentation in October, Jan Altenberg rebutted these claims while offering an overview of the real-time topic.

Altenberg, of German embedded development firm Linutronix, does not deny that dual-kernel approaches such as Xenomai and RTAI offer lower latency. However, he reveals new Linutronix benchmarks that purport to show that the differences are not as great as claimed, especially in real-world scenarios. Less controversially, he argues that RTL is much easier to develop for and maintain.

Before we delve into the eternal Xenomai vs. RTL debate, note that in October 2015, the Open Source Automation Development Lab (OSADL) handed control of the RTL project over to The Linux Foundation, which hosts Linux.com. In addition, Linutronix is a key contributor to the RTL project and hosts its x86 maintainer.

The advance of RTL is one of several reasons Linux has stolen market share from real-time operating systems (RTOSes) over the past decade. RTOSes appear more frequently on microcontrollers than applications processors, and it's easier to do real-time on single-purpose devices that lack advanced userland OSes such as Linux.

Altenberg began his presentation by clearing up some common misconceptions about real-time (or realtime) deterministic kernel schemes. “Real-time is not about fast execution or performance,” Altenberg told his ELCE audience. “It’s basically about determinism and timing guarantees. Real-time gives you a guarantee that something will execute within a given time frame. You don’t want to be as fast as possible, but as fast as specified.”

Developers tend to use real-time when a tardy response to a given execution time leads to a serious error condition, especially when it could lead to people getting hurt. That’s why real-time is still largely driven by the factory automation industry and is increasingly showing up in cars, trains, and planes. It’s not always a life-and-death situation, however -- financial services companies use RTL for high-frequency trading.

Requirements for real-time include deterministic timing behavior, preemption, priority inheritance, and priority ceiling, said Altenberg. “The most important requirement is that a high-priority task always needs to be able to preempt a low-priority task.”

Altenberg strongly recommended against using the term “soft real-time” to describe lightweight real-time solutions. “You can be deterministic or not, but there’s nothing in between.”

Dual-kernel Real-time

Dual-kernel schemes like Xenomai and RTAI deploy a microkernel running in parallel with a separate Linux kernel, while single kernel schemes like RTL make Linux itself capable of real-time. “With dual-kernel, Linux can get some runtime when priority real-time applications aren’t running on the microkernel,” said Altenberg. “The problem is that someone needs to maintain the microkernel and support it on new hardware. This is a huge effort, and the development communities are not very big. Also, because Linux is not running directly on the hardware, you need a hardware abstraction layer (HAL). With two things to maintain, you’re usually a step behind mainline Linux development.”

The challenge with RTL, and the reason it has taken so long to emerge, is that “to make Linux real-time you have to basically touch every file in the kernel,” said Altenberg. Yet, most of that work is already done and baked into mainline, and developers don’t need to maintain a microkernel or HAL.

Altenberg went on to explain the differences between the RTAI and Xenomai. “With RTAI, you write a kernel module that is scheduled by a microkernel. It’s like kernel development -- really hard to get into it and hard to debug.”

RTAI development can be further complicated because industrial customers often want to include closed source code along with GPL kernel code. “You have to decide which parts you can put into userland and which you put into the kernel with real-time approaches,” said Altenberg.

RTAI also supports fewer hardware platforms than RTL, especially beyond x86. The dual-kernel Xenomai, which has eclipsed RTAI as the dominant dual-kernel approach, has wider OS support than RTAI. More importantly, it offers “a proper solution for doing real-time in userspace,” said Altenberg. “To do this, they implemented the concept of skins -- an emulation layer for the APIs of different RTOSes, such as POSIX. This lets you reuse a subset of existing code from some RTOSes.”

With Xenomai, however, you still need to maintain a separate microkernel and HAL. Limited development tools are another problem. “As with RTAI, you can’t use the standard C library,” said Altenberg. “You need special tools and libraries. Even for POSIX, you must link to the POSIX skin, which is much more complicated.” With either platform, he added, it’s hard to scale the microkernels beyond 8 to 16 CPUs to the big server clusters used in financial services.

Sleeping Spinlocks

The dominant single-kernel solution is RTL, based on PREEMPT.RT, which was primarily developed by Thomas Gleixner and Ingo Molnár more than a decade ago. PREEMPT.RT reworks the kernel’s “spinlock” locking primitives to maximize the preemptible sections inside the Linux kernel. (PREEMPT.RT was originally called the Sleeping Spinlocks Patch.)

Instead of running interrupt handlers in hard interrupt context, PREEMPT.RT runs them in kernel threads. “When an interrupt arrives, you don’t run the interrupt handler code,” said Altenberg. “You just wake up the corresponding kernel thread, which runs the handler. This has two advantages: The kernel thread becomes interruptible, and it shows up in the process list with a PID. So you can put a low priority on non-important interrupts and a higher priority on important userland tasks.”

Because about 80 percent of PREEMPT.RT is already in mainline, any Linux developer can take advantage of PREEMPT.RT-originated kernel components such as timers, interrupt handlers, tracing infrastructure, and priority inheritance. “When they made Linux real-time, everything became preemptible, so we found a lot of race conditions and locking problems,” said Altenberg. “We fixed these and pushed them back into mainline to improve the stability of Linux in general.”

Because RTL is primarily mainline Linux, “PREEMPT.RT is widely accepted and has a huge community,” said Altenberg. “If you write a real-time application, you don’t need to know much about PREEMPT.RT. You don’t need any special libraries or APIs, just a standard C library, a Linux driver, and POSIX app.”

You still need to run a patch to use PREEMPT.RT, which is updated in every second Linux version. However, within two years, the remaining 20 percent of PREEMPT.RT should make it into Linux, so you “won’t need a patch.”

Finally, Altenberg revealed the results of his Xenomai vs. RTL latency tests. “There are a lot of papers that claim that Xenomai and RTAI are way faster on latency than PREEMPT.RT,” said Altenberg. “But I figured out that most of the time PREEMPT.RT was poorly configured. So we brought in both a Xenomai expert and a PREEMPT.RT expert, and let them configure their own platforms.”

While Xenomai performed better on most tests, and offered far less jitter, the differences were not as great as the 300 to 400 percent latency superiority claimed by some Xenomai boosters, said Altenberg. When tests were performed on userspace tasks -- which Altenberg says is the most real-world, and therefore the most important, test -- the worst-case reaction was about 90 to 95 microseconds for both Xenomai and RTL/PREEMPT.RT, he claimed.

When they isolated a single CPU in the dual Cortex-A9 system for handling the interrupt in question, which Altenberg says is fairly common, PREEMPT.RT performed slightly better, coming in around 80 microseconds. (For more details, check out the video about 33 minutes in.)

Altenberg acknowledges that his 12-hour test is the bare minimum, compared to OSADL’s two- to three-year tests, and that it is “not a mathematical proof.” In any case, he suggests that RTL deserves a handicap considering its easier development process. “In my opinion, it’s not fair to compare a full-featured Linux system with a microkernel,” he concluded.  

For more details, watch the complete presentation below:


本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Inside Real-Time Linux 的相关文章

  • 系统调用:sys_exit()、SYS_exit 和 exit() 之间的区别

    SYS exit sys exit 和 exit 之间有什么区别 我的理解是 Linux内核提供了系统调用 这些调用在man 2 syscalls 这些系统调用的包装函数由glibc它们的名称与系统调用大多相似 我的问题 在man 2 sy
  • 如何找到与日期范围最重叠的时间段

    假设您有一个包含标识符 开始时间和结束时间的表 这些开始和结束时间可以是任意时间长度 开始时间始终早于结束时间 假设没有空值 什么样的查询会告诉我最 流行 的时间 即每行中的两个范围与大多数其他行重叠的位置 它的实际应用是它是一个记录用户登
  • 访问单个结构体成员是否会将整个结构体拉入缓存?

    我一直在读乌尔里希 德雷珀的书 每个程序员都应该了解的内存知识 http lwn net Articles 250967 并在部分3 3 2 缓存效果的测量 http lwn net Articles 252125 页面中间 它给我的印象是
  • Python:文本覆盖在所有窗口顶部,包括 Linux 中的全屏

    我正在尝试用 python 编写一个简单的脚本 在所有窗口和全屏应用程序之上输出文本 该脚本的目的是以类似于 Steam FPS 计数器工作方式的方式输出平均负载和可用内存 以及其他有用的统计数据 到目前为止 我尝试了 pygame 但据我
  • ELF 文件头

    关于 elf 文件头的一个简单问题 我似乎找不到任何关于如何在 elf 头中添加 更改字段的有用信息 我希望能够更改幻数并向标题添加构建日期 以及可能的其他一些内容 据我了解 链接器创建标头信息 但我在 LD 脚本中没有看到任何引用它的内容
  • 编辑 CMakeLists.txt 以使用 -fPIC 进行编译

    我正在尝试为名为 libnifalcon 的 NOVINT Falcon 安装驱动程序 我使用 cmake 创建 make 文件 但是当我运行 make 时出现错误 Linking CXX shared library lib libnif
  • 如何在 ssh 命令中使用长输入参数正确转义 qsub 命令?

    我有一个复杂的 qsub 命令可以远程运行 PROJECT NAME TEXT TEST PROJECT PACK ORGANIZATION source organization MY ORGANIZATION CONTACT NAME
  • 通过元层覆盖 Yocto 类

    感谢您的时间和支持 我计划使用 swupdate 进行更新 因此 我需要创建一个额外的分区来存储恢复分区 poky meta classes image live bbclass 是创建分区并刷新根文件系统的类 我已更新上述文件以再创建一个
  • 如何编写写入 /var/log/myapp 目录的 C/C++ 应用程序?

    背景 在 Linux 系统上 应用程序日志 https help ubuntu com community LinuxLogFiles Application Logs存在于子目录中 var log 其所有者为root root并且在我的系
  • 如何找到某个命令的目录?

    我知道 当您使用 shell 时 唯一可以使用的命令是可以在 PATH 上设置的某些目录中找到的命令 即使我不知道如何查看 PATH 变量上的目录 这是另一个可以回答的好问题 我想知道的是 我来到 shell 并写道 lshw 我想知道 s
  • Linux 上的最大子进程数

    下面的代码将产生尽可能多的子级 自己不会进一步fork 一旦父进程退出就会变成僵尸 父进程将产生多少个子进程 int main int argc char arg while fork gt 0 子进程的数量可以通过以下方式限制设置限制 2
  • 使用端口 80 (Ubuntu / Linode) 运行 Node.js 的最佳实践 [关闭]

    Closed 这个问题是基于意见的 help closed questions 目前不接受答案 我正在设置我的第一个Node js服务器上的cloud Linux node我对以下细节还很陌生Linux admin 顺便说一句 我并没有尝试
  • 哪个信号被传递到信号处理程序中死锁的进程

    我有一个来自调用信号处理程序后死锁的进程的核心转储 如何确定传送了哪个信号以及是谁发送的 GDB 为接收信号的线程生成的回溯如下 信号处理程序在第 15 帧中被调用 gdb bt 0 0x00007fa9c204654b in sys fu
  • c 中的分叉和管道过程

    所以我有一个项目要做 但我完全被难住了 我花了十个小时却一无所获 我并不是特别想要答案的代码 但是一些伪代码和正确方向的良好提示将有帮助 它分叉多个进程 k 命令行参数 通过管道连接 每个进程都连接到下一个进程 最后一个进程连接到第一个进程
  • 通过 C 将线程固定到 cpuset 中的核心

    我有 cgroup cpuset set1 set1有2 5 8 我想将一个进程绑定到该 cpuset 然后将该进程中的一个线程固定到核心 4 cpuset 的名称 线程名称以及我应该将线程绑定到的核心位于 m 配置文件中 是否有任何 C
  • 如何让SSH命令执行超时

    我有一个这样的程序 ssh q email protected cdn cgi l email protection exit echo output value gt 在上面的代码中 我尝试通过 SSH 连接到远程服务器 并尝试检查是否可
  • Bash:更新文件中的变量

    我知道这是一个简单的答案 在找到答案之前我可能可以继续在谷歌上进行挖掘 但我的日程很紧 我希望能得到一个轻松的答复 我需要在安装时更新 ifcfg eth0 中的变量 换句话说 这就是需要发生的事情 以下变量需要更改 ONBOOT no B
  • PHP 日期/时间格式,需要一些帮助

    你能帮我使用 PHP 格式化以下日期吗 变量 start 包含以下日期 这个日期 Wed Feb 01 2012 05 00 00 GMT 080 应该成为 2012 02 01T13 00 00 我知道如何使用基本的 PHP 日期 时间格
  • x86-64 上这个语句有什么问题?

    该函数的目的是获取堆栈的起始地址 unsigned long find start void asm movq rsp eax 当我编译它时 出现错误 Error suffix or operands invalid for movq mo
  • 即使退出命令后,Shell 脚本仍继续运行

    我的shell脚本如下所示 bin bash Make sure only root can run our script EUID ne 0 echo This script must be run as root 1 gt 2 exit

随机推荐

  • Oracle、MySQL、SQL Server数据库的jdbc连接驱动配置

    Oracle MySQL SQL Server数据库的jdbc连接驱动配置 Oracle jdbc driver 61 oracle jdbc driver OracleDriver 或者 oracle jdbc OracleDriver
  • PID调参详解1

    PID调参详解1 xff08 比例环节 xff09 PID控制中有P I D三个参数 xff0c 只有明白这三个参数的含义和作用才能完成控制器PID参数调整 下面我们分别通过实例来分析比例微分积分三个环节对系统输出的影响 上式为PID控制器
  • NVIDIA NX刷机,配置深度学习环境

    买来的NVIDIA NX自带了一个sd卡和一个ssd卡 xff0c 刚开始按照sdkmanager去安装系统 xff0c 结果安装后发现装到了sd卡上 xff0c 后又根据视频教程在ssd上安装了系统 xff0c 最后配置了深度学习的环境
  • 串口调试助手VC源程序及详细编程过程

    串口调试助手VC源程序 及编程详细过程 作者 xff1a 龚建伟 可以任意转载 xff0c 注明作者和说明来自 龚建伟技术主页 目次 xff1a 1 建立项目 2 在项目中插入MSComm控件 3 利用ClassWizard定义CMSCom
  • linux 下 pytorch 安装

    我的显卡是gtx 730M 已经安装linux版本的驱动 xff0c 安装环境centos8 xff0c 内核版本Linux localhost localdomain 4 18 0 305 19 1 el8 4 x86 64 1 xff0
  • 章文嵩:怎样做开源才有意义?

    转至 xff1a http www infoq com cn interviews how to make open source meaningful utm campaign 61 infoq content amp utm sourc
  • seL4 构建和测试

    转载至 xff1a https source2014 hackpad com seL4 IJItb9IDncR 取得核心程式碼 預先設定好 Toolchain http sel4 systems Download DebianToolCha
  • [小技巧] ping 的时间间隔

    ping 可以选择间隔一段时间的间隔值 使用 i 命令 参考 xff1a 隔一秒钟ping一次 ping i 1 127 0 0 1 PING 127 0 0 1 127 0 0 1 56 84 bytes of data 64 bytes
  • [R语言] quantmod 包获取国内的股票数据

    2016 05 09追加 xff1a 对应的quantmod包相关说明参考 http www quantmod com quantmod 包默认是访问 yahoo finance 的数据 xff0c 其中包括上证和深证的股票数据 xff0c
  • 文件名日文乱码处理

    文件名出现日文乱码的话可以用如下命令解决 xff1a convmv r t utf 8 notest path to dir 另外 xff0c 压缩的 zip 解压时使用如下命令 xff1a unzip Ocp932 path to zip
  • can 总线介绍

    CAN xff0c 全称为 CONtroller Area Network xff0c 即控制器局域网 xff0c 是国际上应用最广泛的现场总线之一 最初 xff0c CAN被设计作为汽车环境中的微控制器通讯 xff0c 在车载各电子控制装
  • python 的 do ~ while 语法

    本文摘至 http ama ch hatenablog com entry 20080425 1209110237 Python不支持do while语法 while xff08 无限循环 xff09 和break组合起来替换 do whi
  • 802.11协议帧格式、Wi-Fi连接交互过程、无线破解入门研究

    本文转载至 xff1a http www cnblogs com littlehann p 3700357 html 目录 1 802 11标准简介 2 802 11协议格式 3 Wi Fi认证过程 4 802 11标准中的数据安全加密协议
  • Make 命令教程

    转载至 xff1a http www ruanyifeng com blog 2015 02 make html 作者 xff1a 阮一峰 日期 xff1a 2015年2月20日 代码变成可执行文件 xff0c 叫做编译 xff08 com
  • Python中用于计算对数的log()方法

    本文转载至 xff1a http www jb51 net article 66130 htm 这篇文章主要介绍了Python中用于计算对数的log 方法 是Python入门基础中的必会的方法 需要的朋友可以参考下 log 方法返回x的自然
  • RT-Thread创始人熊谱翔: 我和Linux、嵌入式实时操作系统RT-Thread

    本文转载至 xff1a http www rt thread org dynamic 78 html 接触 Linux 说起 Linux应该从我在校园时期说起 我是在山城 重庆邮电学院念的书 xff0c 1998年时宿舍伙伴一起凑的钱买的电
  • 到底什么是Unikernel?

    本文转载至 xff1a http dockone io article 855 utm source 61 tuicool amp utm medium 61 referral 编者的话 本文介绍了一种新的应用虚拟化技术 xff0c 它让应
  • xauth: “timeout in locking authority file /home/<user>/.Xauthority”?

    本文转载至 xff1a http unix stackexchange com questions 215558 why am i getting this message from xauth timeout in locking aut
  • 小技巧:检查你本地及公共 IP 地址

    本文转载至 xff1a https linux cn article 8207 1 html utm source 61 rss amp utm medium 61 rss 你本地的 IP 地址 xff1a 192 168 1 100 上面
  • Inside Real-Time Linux

    本文转载于 xff1a https www linux com news event elce 2017 2 inside real time linux Real time Linux has come a long way in the