Skip to content
We areTOP 1%

What is the difference between preemptive and non-preemptive scheduling?

EasyConceptCPU Scheduling
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

In non-preemptive scheduling, a process that gets the CPU keeps it until it finishes or blocks on its own, for example to wait for I/O. In preemptive scheduling, the OS can take the CPU away from a running process, typically when its time slice ends or a more urgent process arrives, and put it back in the ready queue.

  • Non-preemptive algorithms: FCFS, SJF and non-preemptive priority. They are simple and cause few context switches, but one long job can make everyone else wait.
  • Preemptive algorithms: Round Robin, SRTF (Shortest Remaining Time First) and preemptive priority. They give better response time and stop any process from hogging the CPU, at the cost of more context switches and more care with shared data.
  • Linux, Windows and macOS all use preemptive scheduling.

Example: P1 arrives at time 0 needing 8 units, and P2 arrives at time 1 needing 2.

Non-preemptive SJF: only P1 is present at time 0, so it runs 0–8 and P2 runs 8–10. Waiting times: P1 = 0, P2 = 8 − 1 = 7, average 3.5.

Preemptive SRTF: at time 1, P2 needs 2 units while P1 still needs 7, so P1 is preempted: P1 runs 0–1, P2 runs 1–3, P1 runs 3–10. Waiting times: P2 = 0, P1 = 10 − 8 = 2, average 1.

More in CPU Scheduling

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account