Preemptive vs Non-Preemptive Scheduling
What you'll learn: You'll understand the two fundamental approaches for deciding whether the operating system can forcibly take the CPU away from a running process.
The Core Distinction
When a process starts running on the CPU, the scheduler must follow one of two philosophies:
Non-preemptive scheduling means once a process gets the CPU, it keeps it until it voluntarily gives it up—either by finishing, waiting for I/O, or explicitly yielding. The OS cannot interrupt and remove it mid-execution.
Preemptive scheduling means the OS can forcibly interrupt a running process and assign the CPU to another process, even if the current one isn't finished and hasn't blocked.
Think of It Like This
Imagine a classroom with one computer:
- Non-preemptive: A student sits down and uses the computer until they're done with their task or voluntarily step away. Even if they take hours, no one can force them off.
- Preemptive: A teacher can tap the student on the shoulder after their time is up and give someone else a turn, ensuring fairness.
Why It Matters
Non-preemptive scheduling is simpler (no interruptions to manage), but can lead to one long process hogging the CPU while others wait indefinitely.
Preemptive scheduling requires more overhead (context switches, timing mechanisms) but enables fairness, responsiveness, and the ability to prioritize urgent tasks. Most modern operating systems use preemptive scheduling to ensure interactive programs stay responsive.
Key Takeaway: Non-preemptive schedulers wait for processes to voluntarily release the CPU, while preemptive schedulers can forcibly interrupt running processes to maintain fairness and responsiveness.