Preemptive priority scheduling, explained
8 November 2026 · 1 min read
- Operating Systems
- CPU scheduling
Preemptive priority scheduling follows the same rule as the non-preemptive version, but it also checks every time a new process arrives. If the newcomer has a higher priority than the running process, it takes the CPU immediately.
The interrupted process goes back to waiting, with whatever time it still needs.
How it works
- At every arrival, compare the priorities of the waiting processes and the running one.
- Pick the process with the lowest priority number. A tie never makes the running process switch.
- Run it until it finishes or until a process arrives, then choose again.
A small example
Four processes, A to D:
Arrival times: 0 2 4 5
Burst times: 7 4 1 4
Priorities: 3 1 4 2 (a lower number means a higher priority)A starts, but B arrives at time 2 with a higher priority and takes over. D arrives later with priority 2, which is not higher than B, so B finishes first. The average waiting time is:
5.0 time unitsProcess C, with the lowest priority, still waits the longest.
What to know about its cost
- It is preemptive, so urgent work starts straight away.
- It causes more context switches than the non-preemptive version.
- Starvation is still possible without aging.
Where it works well
- Urgent work gets the CPU as soon as it arrives.
- Suits systems with clear levels of importance.
Where it struggles
- Low-priority processes can starve.
- Priorities do not take burst time into account.
Try it yourself
Open the CPU Scheduling experiment, enter the processes from this post, choose Preemptive Priority and step through the Gantt chart. Watch for the point where the higher-priority process interrupts the running one. Then try the other algorithms on the same processes and compare the averages.