Course contentsShow
← Computer Science
Lesson 1257 of 2,87229. CPU SchedulingFree lesson

Priority Scheduling: Preemptive vs Non-Preemptive

Compare preemptive priority scheduling that can interrupt running processes versus non-preemptive that waits for completion.

Priority Scheduling: Preemptive vs Non-Preemptive

What you'll learn: How priority scheduling behaves differently when it can (or cannot) interrupt a running process.

The Core Difference

You've already learned that priority scheduling assigns each process a priority value and selects the highest-priority process to run. But when does the scheduler make these decisions?

Non-preemptive priority scheduling waits politely. Once a process starts running, it continues until it voluntarily gives up the CPU (by finishing or blocking for I/O). If a higher-priority process arrives while another is running, it must wait in the ready queue.

Preemptive priority scheduling is more aggressive. The moment a higher-priority process becomes ready, the scheduler immediately interrupts the currently running process, performs a context switch, and gives the CPU to the newcomer. The interrupted process returns to the ready queue.

Real-World Analogy

Think of an emergency room:

  • Non-preemptive: A doctor treats each patient completely before seeing the next one, even if someone with a more critical condition arrives mid-treatment.
  • Preemptive: If a heart attack victim arrives while the doctor is treating a sprained ankle, treatment stops immediately and the critical patient gets attention now.

When Each Makes Sense

Non-preemptive is simpler and has lower context-switching overhead, but high-priority processes might wait unnecessarily.

Preemptive ensures urgent tasks get immediate attention—crucial for real-time systems or interactive responsiveness—but increases context switches and complexity.

Key Takeaway: Non-preemptive priority scheduling completes each process before checking priorities again; preemptive priority scheduling interrupts the running process immediately when a higher-priority one arrives, ensuring critical tasks get the CPU fastest.