The key difference between preemptive and non-preemptive scheduling in OS is that preemptive scheduling takes place when a process runs from running state to ready state whereas non-preemptive scheduling takes place when the process is terminating.
The operating system is a bridge between user and software, the operating system in computer science is the most important concept. In the operating system, preemptive and non-preemptive scheduling is the most important concept.
There is a CPU scheduler that is responsible for allotting a process to CPU. CPU scheduler waits for the CPU to get free and when the CPU resources are free, it makes the way of other processes. Preemptive scheduling takes place when a process runs from running state to ready state whereas non-preemptive scheduling takes place when the process is terminating. In preemptive scheduling, processes can be scheduled whereas non-preemptive scheduling processes cannot be scheduled.Preemptive scheduling happens when process switches from running state to ready state. In preemptive scheduling CPU cycles are allocated to process and that is for limited period of time. The process that need to be waited is in ready queue and it wait for CPU burst. The process have to stay in ready queue until CPU is ready for execution. Then there are priorities that a process that will come with high priority will get the resources first then the process with less priorities. This whole process is known as preemptive scheduling. Robin Robin is an example of preemptive scheduling.
Non-preemptive scheduling take place when process is terminating. When the process is having the resource by the CPU and when the resource is used by that process the process is terminated by the CPU. Preemptive scheduling interrupt the process as soon as the process with high priority comes and in the case of non-preemptive scheduling there is no interruption and the process is terminated when the process is completed. When the process with long CPU burst time is executing then the process will have to wait and in this way the average waiting time increases.
Comparison Chart
Basis | Preemptive Scheduling | Non-preemptive Scheduling |
Meaning | Preemptive scheduling take place when process run from running state to ready state |
Non-preemptive scheduling take place when process is terminating.
|
Interrupt | There is an interruption in preemptive scheduling | There is no interruption in non-preemptive scheduling |
Flexible | Preemptive scheduling is flexible | Non-preemptive scheduling is not flexible |
Cost | Preemptive scheduling is cost effective | Non-preemptive scheduling is not cost effective |
Preemptive Scheduling
Preemptive scheduling happens when process switches from running state to ready state. In preemptive scheduling, CPU cycles are allocated to process, and that is for a limited period of time. The process that needs to wait is in ready queue, and it waits for CPU burst. The process has to stay in ready queue until CPU is ready for execution. Then there are priorities that a process that will come with high priority will get the resources first then the process with fewer priorities. This whole process is known as preemptive scheduling. Robin Robin is an example of preemptive scheduling.
Non-preemptive Scheduling
Non-preemptive scheduling take place when process is terminating. When the process is having the resource by the CPU and when the resource is used by that process the process is terminated by the CPU. Preemptive scheduling interrupt the process as soon as the process with high priority comes and in the case of non-preemptive scheduling there is no interruption and the process is terminated when the process is completed. When the process with long CPU burst time is executing then the process will have to wait and in this way the average waiting time increases.
Key Differences
- Preemptive scheduling takes place when a process runs from running state to ready state whereas Non-preemptive scheduling takes place when the process is terminating.
- There is an interruption in preemptive scheduling whereas there is no interruption in non-preemptive scheduling.
- Preemptive scheduling is flexible whereas non-preemptive scheduling is not flexible.
- Preemptive scheduling is cost effective whereas non-preemptive scheduling is not cost effective
Conclusion
In this article above we see the clear difference between preemptive and non-preemptive scheduling with examples.