英文:
Linux Kernel thread preemption
问题
I am having a doubt on the premptiveness of the Linux kernel. I know that user space processes and threads are premptible, but what about kernel level threads, those created using kthread_create
.
如果一个线程使用 kthread_create
创建,它是否可以被调度程序抢占,以便执行另一个内核线程?
If a thread is created using kthread_create
, can it be preempted by scheduler and another kernel thread be executed?
如果假设内核线程只执行 while(1) {}
,它是否会一直运行到完成,占用一个特定的CPU,或者调度程序可以调度出该线程?它是否会引发 softlockup 消息?
If suppose the kernel thread just performs while(1) {}
, will it always run to completion occupying a particular CPU, or the scheduler can schedule out the thread? Can it cause softlockup message?
我正在尝试理解RCU,但我意识到,我需要首先了解可抢占和不可抢占内核。
I am trying to understand RCU, but I realised, I need to understand, preemptive non-preemptive kernels first.
英文:
I am having a doubt on the premptiveness of the Linux kernel. I know that user space processes and threads are premptible, but what about kernel level threads, those created using kthread_create
.
If a thread is created using kthread_create
, can it be preempted by scheduler and another kernel thread be executed?
If suppose the kernel thread just performs while(1) {}
, will it always run to completion occupying a particular CPU, or the scheduler can schedule out the thread ? Can it cause softlockup message?
I am trying to understand RCU, but I realised, I need to understand, preemptive non-preemptive kernels first.
答案1
得分: 1
是的,内核线程(例如使用 kthread_create()
创建的线程)是可抢占的。就调度而言,内核线程和用户空间线程在处理上都是相同的方式对待的。参见:Linux 内核线程的默认调度策略是什么?
英文:
Yes, kernel threads (created e.g. with kthread_create()
) are preemptible. For all it matters, kthreads and userspace threads are treated in the same way when it comes to scheduling. See also: What is the default scheduling policy of a Linux kernel thread?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论