Pre-emptive vs. Non-pre-emptive kernel
It is clear to me how pre-emptive scheduling in user space is of benefit to efficiency. However, I do not understand why having a pre-emptive kernel would be of any particular benefit. What is a scenario in which a preemptive kernel would be much better than a nonpreemptive kernel?
|
As I understand it historically, a pre-emptive kernel forcibly timeslots processes, regardless of the processes desire to continue processing. A non-preemptive kernel allows processes to utilize the processor until they are ready to give it up. In the scenario of a non-preemptive kernel, a single process could easily hog the machine's processing time, and in effect, bring the machine to a halt.
If you think of a kernel as a vehicle intersection, a preemptive kernel will have stop lights to control how much time each lane of cars may move, giving cars in opposite lanes the time they need to move also. |
I'm not sure, but I think he's refering to the kind of preemption where the processor is executing kernel code and it is preempted to execute some other kernel code.
In that case I have the same doubt, but I think a possible scenario would be when the processor is executing kernel code on some process' behalf (not for example scheduling code), for example a system call, and there the processor is preempted to execute some other higher priority process' kernel code (another system call which follows its execution due to a ready I/O device, or something). This is just a guess, so please tell me what you think... |
This is what I'm talking about: http://www.webopedia.com/TERM/m/multitasking.html
|
Try this kernelnewbies article.
Very good site BTW. |
Now I'm sure :)
What you're talking about is process preemption, or preemptive scheduling, and what you explain is correct. It is about how the currently running process can be preempted when a process of higher priority changes to the TASK_RUNNING state (regardless of the Mode the original process was running in). See section Process Preemption from Chapter 10 of Understanding the Linux Kernel. But a slightly different thing is Kernel Preemption, which basically defines if the currently running process can be preempted while it is executing specifically kernel code (i.e. a system call) and switched to the kernel code of another higher priority process which becomes runnable (i.e. a process waiting inside a read() syscall waking up because the user pressed a key). You can read this from section Kernel Preemption from Chapter 5 of the same book. And jhwilliams, in the last link you can read about how Kernel Preemption reduces dispatch latency and how this benefits some kind of processes (movie players, etc). Learning too! :) |
Great link syg00...
Forum threads should have spinlocks too :P |
Cheers - it should be noted that Ingo is about to make all this discussion moot.
Do a search on CFS - I was involved in a thread here recently. |
All times are GMT -5. The time now is 08:36 PM. |