Linux Kernel thread preemption

257 Views Asked by At

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

There are 1 best solutions below

0
Marco Bonelli On

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?