在 Linux 内核源代码中,文件 Documentation/scheduler/sched-arch.txt
包含以下行。
Your cpu_idle routines need to obey the following rules:
Preempt should now disabled over idle routines. Should only be enabled to call schedule() then disabled again.
我是 Linux 内核世界的新手,所以我可以为 cpu_idle
例程的实现者想到第一行的三种可能解释。
- 我们应该假设抢占被禁用。
- 我们应该验证抢占被禁用
- 我们应该确保禁用抢占。
有更多内核经验的人知道正确的解释吗?
最佳答案
哎呀。如果您要添加对新平台的支持,请随时更新该评论。
我很长时间没有进行 Linux 内核开发,但据我所知,它应该说“在运行 cpu_idle 例程时 [内核] 禁用了抢占。你应该只在调用调度时启用它(),然后立即再次禁用它。”
例如,在 PPC idle.c 中,while 循环结束于:
preempt_enable_no_resched();
schedule();
preempt_disable();
否则不涉及抢占。
关于linux - Linux内核文档中的下面这句话是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41528967/