如何“实时”是Linux 2.6吗?
我正在考虑将我的产品从 RTOS 迁移到嵌入式 Linux。我对实时性的要求并不高,少数的 RT 要求都是 10 毫秒左右。
有人可以给我指出一个参考资料,告诉我当前版本的 Linux 的实时性如何吗?
从商业 RTOS 迁移到 Linux 还存在其他问题吗?
I am looking at moving my product from an RTOS to embedded Linux. I don't have many real-time requirements, and the few RT requirements I have are on the order of 10s of milliseconds.
Can someone point me to a reference that will tell me how Real-Time the current version of Linux is?
Are there any other gotchas from moving to a commercial RTOS to Linux?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以从 Real Time Linux wiki 和 常见问题解答
他们还有一个“陷阱”列表,正如您在常见问题解答中所说的那样。
他们还有一个您可能需要的大型出版物页面去结帐。
You can get most of your answers from the Real Time Linux wiki and FAQ
They also have a list of "Gotcha's" as you called them in the FAQ.
They also have a large publications page you might want to checkout.
您看过Xenomai吗?它将允许您在 Linux 上运行“硬实时”进程,同时仍然允许您访问常规 Linux API 以满足所有非实时需求。
Have you had a look at Xenomai? It will let you run "hard real time" processes above Linux, while still allowing you to access the regular Linux APIs for all the non-real-time needs.
使用 Linux 实现实时功能有两种根本不同的方法。
使用 rt-preempt 补丁等修补现有内核。这最终将导致完全抢占式内核
双内核方法(如 xenomai、RTLinux、RTAI...)
从 RTOS 迁移到 Linux 会遇到很多问题。
也许您真的不需要实时?
我在培训课程中谈论实时 Linux:
https://rlbl.me/elisa
< a href="https://rlbl.me/elisa-en-pdf" rel="nofollow noreferrer">https://rlbl.me/elisa-en-pdf
https://rlbl.me/intely
https://rlbl.me/intely-en-pdf
https: //rlbl.me/entirety-en-all-pdf
There are two fundamentally different approaches to achieve real-time capabilities with Linux.
Patch the existing kernel with things like the rt-preempt patches. This will eventually lead to a fully preemptive kernel
Dual kernel approach (like xenomai, RTLinux, RTAI,...)
There are lots of gotchas moving from a RTOS to Linux.
Maybe you don't really need real-time?
I'm talking about real-time Linux in my training sessions:
https://rlbl.me/elisa
https://rlbl.me/elisa-en-pdf
https://rlbl.me/intely
https://rlbl.me/intely-en-pdf
https://rlbl.me/entirety-en-all-pdf
答案可能是“足够好”。
如果您运行的是嵌入式系统,您可能可以控制盒子上的全部或大部分软件。
Stock Linux 2.6 有几个适合低延迟任务的功能 - 主要是:
假设您使用的是单核机器,如果您只有一个任务将其调度策略设置为 SCHED_FIFO 或 SCHED_RR(它如果你只有一个任务,那并不重要),并使用 mlockall() 锁定其所有内存,那么一旦准备好运行,它将立即被调度。
那么您唯一需要担心的是内核的某些不可抢占部分需要比您可接受的延迟更长的时间才能完成 - 这在嵌入式系统中不太可能发生,除非发生不好的事情,例如极端的内存压力,或者你们的司机很狡猾。
我想“尝试一下”是一个很好的答案,但在您的情况下这可能相当复杂(并且可能涉及编写设备驱动程序等)。
查看 sched_setscheduler 的文档以获取一些有用的信息。
The answer is probably "good enough".
If you're running an embedded system, you probably have control of all or most of the software on the box.
Stock Linux 2.6 has several features suitable for low-latency tasks - chiefly these are:
Assuming you're using a single-core machine, if you have just one task which has set its scheduling policy to SCHED_FIFO or SCHED_RR (it doesn't matter which if you have just one task), AND locked all its memory in with mlockall(), then it WILL get scheduled as soon as it is ready to run.
Then the only thing you'd have to worry about was some non-preemptable part of the kernel taking longer than your acceptable latency to complete - which is unlikely to happen in an embedded system unless something bad happens, such as extreme memory pressure, or your drivers are dodgy.
I guess "try it and see" is a good answer, but that's probably rather complicated in your case (and might involve writing device drivers etc).
Look at the doc for sched_setscheduler for some good info.