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.
Best Answer
Whether a kernel is preemptive or not depends on what you want to preempt, as in the Linux kernel, there are various things that can have preemption enabled/disabled separately.
If your kernel has
CONFIG_IKCONFIG
andCONFIG_IKCONFIG_PROC
enabled, you can find out your preemption configuration through/proc/config.gz
(if you don't have this, some distributions ship the kernel config in/boot
instead):If you have
CONFIG_IKCONFIG
, but notCONFIG_IKCONFIG_PROC
, you can still get it out of the kernel image withextract-ikconfig
.