Preemptive vs Non-Preemptive Scheduling
In a multiprogramming system, the CPU must decide which process should run next. This decision-making is handled through process scheduling, which helps maximize CPU usage and ensures efficient execution. A scheduling policy defines how one process is chosen from the ready queue for execution.
Types of Scheduling
Process scheduling techniques are generally divided into two main categories:
- Preemptive Scheduling
- Non-Preemptive Scheduling
Non-Preemptive Scheduling
In non-preemptive scheduling, once a process gets control of the CPU, it continues running until it finishes execution or moves into a waiting state (such as for I/O). The CPU is not taken away from the process in between.
The scheduler assigns the next process only after the current one completely releases the CPU.
Common Examples:
- First-Come-First-Serve (FCFS)
- Shortest Job First (SJF)
- Priority Scheduling (Non-preemptive)
- Highest Response Ratio Next (HRRN)
Advantages:
- Easy to design and implement
- Lower system overhead
- Fewer context switches
- Predictable and consistent behavior
Disadvantages:
- Poor response to dynamic system changes
- May lead to deadlocks in some cases
- A faulty or long-running process can block others completely
Preemptive Scheduling
In preemptive scheduling, the CPU can be taken away from a running process before it finishes. The operating system may interrupt the current process and assign the CPU to another one.
Situations Where Preemption Occurs:
- When a process exceeds its allotted time slice
- When a higher-priority process arrives
- When a shorter job enters the system (e.g., in Shortest Remaining Time scheduling)
Common Examples:
- Round Robin (RR)
- Shortest Remaining Time First (SRTF)
- Priority Scheduling (Preemptive)
Advantages:
- Prevents any single process from dominating the CPU
- Improves response time
- More flexible and adaptive scheduling
- Helps reduce chances of deadlock
Disadvantages:
- Frequent context switching increases overhead
- Requires more memory to store process states
- Low-priority or long processes may suffer starvation
- More complex to implement and manage
Key Differences
| Preemptive Scheduling | Non-Preemptive Scheduling |
|---|---|
| CPU can interrupt a process anytime | Process runs until completion |
| Better responsiveness | Slower response time |
| Higher overhead due to switching | Lower overhead |
| Fair CPU sharing | CPU may be monopolized |
| More complex | Simpler to implement |
| Starvation possible (low priority) | Starvation possible (long jobs) |
| Helps avoid deadlocks | Higher risk of deadlocks |
Knowledge Check
Question 1 of 2Test your understanding of Preemptive and Non-Preemptive scheduling.
