Linux Kernel thread preemption

huangapple go评论56阅读模式
英文:

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?

huangapple
  • 本文由 发表于 2023年5月20日 23:53:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76296082.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定