In an operating system (OS), a process scheduler performs the important activity of scheduling a process between the ready queues and waiting queue and allocating them to the CPU. The OS assigns priority to each process and maintains these queues. The scheduler selects the process from the queue and loads it into memory for execution.
There are two types of process scheduling:
- Preemptive scheduling
- Non-preemptive scheduling
Preemptive Scheduling
The scheduling in which a running process can be interrupted if a high priority process enters the queue and is allocated to the CPU is called preemptive scheduling. In this case, the current process switches from the running queue to ready queue and the high priority process utilizes the CPU cycle.
Non-preemptive Scheduling
The scheduling in which a running process cannot be interrupted by any other process is called non-preemptive scheduling. Any other process which enters the queue has to wait until the current process finishes its CPU cycle.
Difference between Preemptive and Non Preemptive Scheduling
PREEMPTIVE SCHEDULING |
NON PREEMPTIVE SCHEDULING |
The resources are allocated to a process for a limited time. |
Once resources are allocated to a process, the process holds it till it completes its burst time or switches to waiting state. |
Process can be interrupted in between. |
Process cannot be interrupted till it terminates or switches to waiting state. |
If a high priority process frequently arrives in the ready queue, low priority process may starve. |
If a process with long burst time is running CPU, then another process with less CPU burst time may starve. |
Preemptive scheduling has overheads of scheduling the processes. |
Non-preemptive scheduling does not have overheads. |
Preemptive scheduling is flexible. |
Non-preemptive scheduling is rigid. |
Preemptive scheduling is cost associated. |
Non-preemptive scheduling is not cost associative |