Priority Scheduling
Priority scheduling encodes importance. The highest-priority ready process runs next — and low-priority processes may never run unless you add aging.
In plain English
Priority scheduling is a VIP line. The most important job goes first.
By the end you will be able to
- Trace non-preemptive priority scheduling.
- Decide which priority number means higher priority.
- Explain starvation and aging.
- Compare priority scheduling with SJF.
The algorithm
Each process has a priority. At every decision point, choose the highest-priority process among those that have arrived. In non-preemptive priority, run it to completion. In preemptive priority, a newly arrived higher-priority process can interrupt the running one. Be explicit about direction: many systems treat a lower number as higher priority, but the convention is not universal.
time = 0;
while unfinished:
ready = arrived unfinished processes
if ready empty: time = next arrival; continue
p = ready with highest priority
run p to completion
p.completion = timeWorked example
Processes: P1 arrival 0 burst 5 priority 3, P2 arrival 0 burst 3 priority 1, P3 arrival 0 burst 8 priority 2. Lower number = higher priority. P2 runs 0–3, P3 runs 3–11, P1 runs 11–16. Completion: P2 3, P3 11, P1 16. Waiting: P2 0, P3 8, P1 11. Average waiting = 6.33. If P2 keeps arriving, P1 can starve.
| P2 | P3 | P1 |
0 3 11 16Starvation and aging
A low-priority process can wait indefinitely if higher-priority work keeps arriving. Aging gradually increases the priority of waiting processes, so even a low-priority job eventually becomes competitive. Another option is to reserve a share of CPU time for each priority class. Priority scheduling is useful when importance is real, but it needs a starvation policy.
Watch it happen
Step through the worked example. Play it, pause it, or move one step at a time.
step-by-step
Step 1 of 3
t = 0 → 3 · P2
At t=0, P2 has the highest priority among ready processes, so it runs until t=3.
Key takeaways
- Priority scheduling chooses the highest-priority ready process.
- Lower number often means higher priority, but check the convention.
- Non-preemptive priority runs the chosen process to completion.
- Low-priority processes can starve.
- Aging raises priority over time to prevent starvation.
Common pitfalls
- Mixing up which priority number is higher.
- Running a process that has not arrived.
- Forgetting that preemptive priority can interrupt a running process.
Kernel notes
- State the priority direction before solving.
- Trace the ready set at each decision point.
- Explain aging with a concrete low-priority process.
Quick check
1. In a system where lower numbers mean higher priority, which process runs first?
2. What problem does aging solve?