Linux 抢占式内核的影响?

发布于 2024-11-05 20:54:55 字数 64 浏览 1 评论 0原文

Linux 内核抢占式的含义是什么,特别是对于创建设备驱动程序。我猜你需要更加注意资源锁定,但是还有什么其他的吗?

What are the implications of a linux kernel being preemptive, particularly for creating device drivers. I'm guessing you need to be more diligent about resource locking, but is there anything more to this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最近可好 2024-11-12 20:54:55

正如您所提到的,竞争条件的机会有很多,所以是的,您必须非常勤奋地使用锁。您还必须小心时机,例如何时启用/禁用中断或其他硬件资源等。您并不总是需要在这些情况下使用锁,但您可能必须重新排序代码。最后,它还会影响调度,使高优先级任务的响应速度更快,这反过来可能会对低优先级任务产生负面影响。

There are a lot more opportunities for race conditions as you had mentioned, so yes, you have to be very diligent with locks. You also have to be careful about timing, such as when you enable/disable interrupts or other hardware resources, etc. You don't always have to use locks for these situations, but you may have to reorder you code. Finally, it also effects scheduling, allowing high priority tasks to be much more responsive, which in turn may have a negative effect on the lower priority tasks.

來不及說愛妳 2024-11-12 20:54:55

如果不在 SMP 上,请确保需要应用此锁定补丁:“Gaurantee spinlocks 隐式屏障!PREEMPT_COUNT< /a>”,这是在 2013 年 4 月制作的。

请注意,每次代码运行“spin_unlock_”或“preemption_enable”时,都会发生抢占每当异常返回或中断返回时都是一样的。除了这些情况之外,应该没有其他问题。内核设计保证异常和中断以严格嵌入的方式处理,尽管使用 SMP 多个实例可以并行运行。

If not on SMP, make sure this lock patch need to be applied: "Gaurantee spinlocks implicit barrier for !PREEMPT_COUNT", that was made in Apr 2013.

Be aware that each time the code runs "spin_unlock_" or "preemption_enable", a preemption could kick in. It's the same whenever an exception returns or interrupt returns. Beyond those cases and the likes, there should be no other concerns. The kernel design guarantees exceptions and interrupts are handled in strictly embedded manner, though with SMP multiple instances may run in parallel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文