Difference Between Non-preemptive, Preemptive, and Selective Preemptive Kernel

kernellinux

What is the difference between a "Non-preemptive", "Preemptive" and "Selective Preemptive" Kernel?

Hope someone can shed some light into this.

Best Answer

On a preemptive kernel, a process running in kernel mode can be replaced by another process while in the middle of a kernel function.

This only applies to processes running in kernel mode, a CPU executing processes in user mode is considered "idle". If a user mode process wants to request a service from the kernel, he has to issue an exception which the kernel can handle.

As an example:

Process A executes an exception handler, Process B gets awaken by an IRQ request, the kernel replaces process A with B (a forced process switch). Process A is left unfinished. The scheduler decides afterwards if process A gets CPU time or not.

On a nonpreemptive kernel, process A would just have used all the processor time until he is finished or voluntarily decides to allow other processes to interrupt him (a planned process switch).

Today's Linux based operating systems generally do not include a fully preemptive kernel, there are still critical functions which have to run without interruption. So I think you could call this a "selective preemptive kernel".

Apart from that, there are approaches to make the Linux kernel (nearly) fully preemptive.