Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

Hope someone can shed some light into this.

share|improve this question
Reading documentation is not one of your strong skills, apparently... – alex Dec 28 '10 at 7:13
I would really like to know why anyone would want this Question closed. Really, please point why it's not a real question. – Tshepang Dec 28 '10 at 13:56
@Tshepang : On reading the comment by Alex, and -1 flag which i got in just after 5 minutes i posted this question, i thought this one is silly. So i myself asked for closing it. If you find it really valid question, and i should move forward with it, I would like to know how can i pull my closed vote back? – Sen Dec 28 '10 at 14:10
I saw that you asked the other Question. You should maybe have just edited this one. Forget the close vote. It will go away after a number of days. – Tshepang Dec 28 '10 at 15:28

2 Answers

up vote 1 down vote accepted

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.

share|improve this answer
The Macintosh System 6 and related code (e.g., System 7, System 8, and System 9) were all non-preemptive. Apple's switch to MacOS X also saw the introduction of preemptive multitasking as well. – David Feb 4 '12 at 1:25

the preemption is -> The ability of the operating system to preempt or stop a currently scheduled task in favour of a higher priority task. The scheduling may be one of, but not limited to, process or I/O scheduling etc.

Under Linux, user-space programs have always been preemptible : the kernel interrupts user-space programs to switch to other threads, using the regular clock tick. So, the kernel doesn't wait for user-space programs to explicitly release the processor (which is the case in cooperative multitasking). This means that an infinite loop in an user-space program cannot block the system.

However, until 2.6 kernels, the kernel itself was not preemtible : as soon as one thread has entered the kernel, it could not be preempted to execute an other thread. However, this absence of preemption in the kernel caused several problems with regard to latency and scalability. So, kernel preemption has been introduced in 2.6 kernels, and one can enable or disable it using the CONFIG_PREEMPT option. If CONFIG_PREEMPT is enabled, then kernel code can be preempted everywhere, except when the code has disabled local interrupts. An infinite loop in the code can no longer block the entire system. If CONFIG_PREEMPT is disabled, then the 2.4 behaviour is restored.

ReQuoted and formatted from: http://www.linuxquestions.org/questions/linux-general-1/pre-emptive-vs-non-pre-emptive-kernel-582437/

share|improve this answer
Why was 2.4 kernel non-preemptive? – Sen Dec 28 '10 at 10:04
Better ask Linus Torvalds :) – Madhur Ahuja Dec 28 '10 at 10:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.