Appearance
20. Scheduling Algorithms Overview (Preemptive vs Non-Preemptive)
| Non-Preemptive Preemptive | ||
|---|---|---|
| CPU taken forcibly? | No | Yes |
| Response time | Worse | Better |
| Overhead | Low | Higher |
| Starvation risk | Higher | Lower |
| Use case | Batch systems | Interactive / real-time |
Non-preemptive: once a process has the CPU, it keeps it until it finishes or blocks on I/O. Algorithms: FCFS, SJF (non-preemptive), Priority (non-preemptive). Simple, low overhead, but a long process can starve others (the "convoy effect").
Preemptive: the OS can interrupt a running process, typically via a timer interrupt. Algorithms: Round Robin, SRTF, Priority (preemptive). Better responsiveness, but needs synchronization to protect data a process might be preempted mid-update.
Key point: preemption is what makes time-sharing possible; modern OSes (Linux, Windows) are preemptive, at the cost of needing mutexes/semaphores everywhere shared state is touched.