rtlinux

rtlinux 原理

摘抄自: https://rt.wiki.kernel.org/index.php/Frequently_Asked_Questions

How does the CONFIG_PREEMPT_RT patch work?
The RT-Preempt patch converts Linux into a fully preemptible kernel. The magic is done with:
Making in-kernel locking-primitives (using spinlocks) preemptible though reimplementation with rtmutexes.

Critical sections protected by i.e. spinlock_t and rwlock_t are now preemptible. The creation of non-preemptible sections (in kernel) is still possible with raw_spinlock_t (same APIs like spinlock_t).

Implementing priority inheritance for in-kernel spinlocks and semaphores. For more information on priority inversion and priority inheritance please consult Introduction to Priority Inversion.

Converting interrupt handlers into preemptible kernel threads: The RT-Preempt patch treats soft interrupt handlers in kernel thread context, which is represented by a task_struct like a common user space process. However it is also possible to register an IRQ in kernel context.

Converting the old Linux timer API into separate infrastructures for high resolution kernel timers plus one for timeouts, leading to user space POSIX timers with high resolution.

总结:
减少linux的关抢占时间,让高优先级任务能够更快的被调度到运行

  1. 将会关抢占的spinlock改成rtmutext, spinlock变成可抢占
  2. 将中断内核线程化。软中断改成内核线程
  3. 增加优先级继承,解决优先级反锁问题

原生linux 内核抢占选项

  1. CONFIG_PREEMPT_VOLUNTARY
    在内核函数流程中布置了cond_schedule 函数, 即内核里布满了检查是否有高优先级任务可以抢占当前任务的情况
  2. CONFIG_PREEMPT
    — 增加中断在内核态返回以及 抢占打开时的任务抢占切换检查

参考资料

https://blog.csdn.net/rikeyone/article/details/94555165

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值