Difference between Preemptive and Non-Preemptive Kernel in OS
1. Preemptive Kernel :
Preemptive Kernel, as name suggests, is a type of kernel that always executes the highest priority task that are ready to run. It cannot use-non-reentrant functions unless and until functions are mutual exclusive.
Example : Linux 2-6
2. Non-Preemptive Kernel :
Non-Preemptive Kernel, as name suggests, is a type of kernel that is free from race conditions on kernel data structures as only one process is active in kernel at a time. It is considered as a serious drawback for real time applications as it does not allow preemption of process running in kernel mode.
Example : Linux 2.4
Difference between Preemptive and Non-Preemptive Kernel in OS :
Preemptive Kernel | Non-Preemptive Kernel |
---|---|
It is a process that might be replaced immediately. | It is a process that continuous to run until it finishes handling execution handler or voluntarily relinquishes CPU. |
It is more suitable for real time programming as compared to non-preemptive kernels. | It is less suitable for real-time programming as compared to preemptive kernel. |
In this, higher priority task that are ready to run is given CPU control. | In this, each and every task are explicitly given up CPU control. |
It generally allows preemption even in kernel mode. | It generally does not allow preemption of process running in kernel mode. |
Responsive time is deterministic and is more responsive as compared to non-preemptive kernel. | Response time is nondeterministic and is less responsive as compared to preemptive kernel. |
Higher priority task becomes ready, currently running task is suspended and moved to ready queue. | Higher priority task might have to wait for long time. |
It does not require semaphores. | Shared data generally requires semaphores. |
It cannot use non-reentrant code. | It can use non-reentrant code. |
It is more difficult to design preemptive kernels as compared to non-preemptive kernel. | It is less difficult to design non-preemptive kernels as compared to preemptive kernels. |
They are more secure and more useful in real-world scenarios. | They are less secure and less useful in real-world scenarios. |