Preemptive vs Non-Preemptive Scheduling
The scheduler has two very different powers: wait for a process to yield, or take the CPU away. The choice changes responsiveness, overhead, and correctness.
In plain English
Preemptive means the scheduler can tap you on the shoulder and take the CPU. Nonpreemptive means you finish first.
By the end you will be able to
- Define preemptive and non-preemptive scheduling.
- Identify the events that can trigger preemption.
- Explain the cost of preemption.
- Classify common algorithms as preemptive or non-preemptive.
Non-preemptive scheduling
A non-preemptive scheduler lets a running process continue until it blocks or finishes. FCFS and non-preemptive SJF/priority work this way. The advantage is fewer context switches and simpler kernel data structures. The disadvantage is that a long or buggy CPU-bound process can delay everyone behind it, and interactive response can suffer.
Preemptive scheduling
A preemptive scheduler can interrupt a running process at a safe point, usually on a timer tick or when a higher-priority process arrives. Round Robin, SRTF, and preemptive priority are preemptive. The timer interrupt is the key mechanism: without it, a process could keep the CPU forever. Preemption improves responsiveness but requires careful synchronization and adds switch overhead.
/* timer-driven preemption */
on_timer_tick():
if current_process_used_quantum():
current.state = READY
schedule_next()Choosing a policy
Interactive systems favor preemption because response time matters. Batch systems may prefer non-preemptive policies to reduce overhead. Real-time systems use preemption with bounded latency. The right answer depends on the workload and the metric, not on a universal rule.
Key takeaways
- Non-preemptive scheduling waits for the process to block or finish.
- Preemptive scheduling can interrupt a running process.
- Timer interrupts enable preemption.
- Preemption improves responsiveness but adds overhead.
- FCFS and non-preemptive SJF are non-preemptive; RR and SRTF are preemptive.
Common pitfalls
- Assuming all priority scheduling is preemptive; it can be either.
- Ignoring the cost of frequent preemption.
- Forgetting that preemption needs a safe point and saved state.
Kernel notes
- Classify FCFS, SJF, SRTF, RR, and priority.
- Name the event that triggers preemption.
- Explain the trade-off in terms of response time and overhead.
Quick check
1. Which mechanism commonly triggers preemption?
2. Which algorithm is preemptive?