# Priority Scheduling

> Priority scheduling is a CPU scheduling algorithm that always runs the ready process with the highest priority, in either preemptive or non-preemptive form. Its main risk is starvation, where low-priority processes wait indefinitely while higher-priority ones keep arriving, and the standard fix is aging, which gradually raises a waiting process's priority.

Canonical: https://devsunite.com/resources/core-subjects/operating-systems/priority-scheduling
Last updated: 2026-11-22

Subject: Operating Systems · Category: Process Scheduling · 3 min read

Priority scheduling assigns each process a priority value, and the scheduler always picks whichever ready process has the highest priority (conventions vary: sometimes a lower number means higher priority, sometimes higher means higher, always check which convention a specific system or textbook problem is using).

## Preemptive vs non-preemptive priority scheduling

In non-preemptive priority scheduling, a running process keeps the CPU until it finishes or blocks, even if a higher-priority process arrives in the meantime; the new arrival just waits its turn.

In preemptive priority scheduling, if a newly-arrived process has higher priority than whatever's currently running, the scheduler immediately preempts the running process in favor of the new, higher-priority one.

## A worked example (preemptive)

Assume lower number means higher priority. Three processes:

| Process | Arrival Time | Burst Time | Priority |
|---------|---------------|------------|-----------|
| P1 | 0 | 6 | 3 |
| P2 | 2 | 4 | 1 |
| P3 | 4 | 2 | 2 |

At time 0, only P1 exists, so it runs. At time 2, P2 arrives with priority 1, higher priority than P1's 3, so P1 is preempted and P2 starts running.

At time 4, P3 arrives with priority 2, lower priority than P2's 1 (P2 is still higher), so P2 continues uninterrupted. P2 finishes its full 4 units at time 6 (started at 2, ran uninterrupted since nothing beat its priority).

At time 6, compare remaining candidates: P3 (priority 2, waiting since 4) and P1 (priority 3, remaining time 4, since it ran for 2 units before being preempted). P3 has higher priority, so P3 runs next, from 6 to 8. Finally P1 resumes, running its remaining 4 units from 8 to 12.

## The starvation problem, and its fix

If high-priority processes keep arriving continuously, a low-priority process can wait indefinitely, never actually getting the CPU even though it's theoretically still eligible (this is exactly the starvation topic covered elsewhere, applied specifically to priority scheduling). The standard fix is aging: gradually increase a waiting process's effective priority the longer it waits, guaranteeing it eventually becomes high-priority enough to run regardless of what new arrivals show up.

## Where this matters in real systems

Priority-based scheduling with aging is genuinely how most real operating system schedulers work under the hood, including Linux's, which assigns processes both a base priority (partly user/system-configurable via "niceness" values) and dynamically adjusts effective priority based on recent behavior, explicitly to avoid the exact starvation risk plain priority scheduling has on its own.

## What interviewers actually ask about priority scheduling

- **"What is priority scheduling?"** Always running whichever ready process has the highest priority value, either preemptively (interrupting a lower-priority running process when a higher-priority one arrives) or non-preemptively (letting the running process finish regardless).
- **"What's the major risk of pure priority scheduling?"** Starvation of low-priority processes if high-priority ones keep arriving continuously.
- **"How do you fix starvation in priority scheduling?"** Aging, gradually raising a waiting process's effective priority over time.
- **"How does Linux's real scheduler relate to this?"** It uses priority-like concepts (including user-adjustable "niceness") combined with dynamic, fairness-aware adjustments, explicitly to avoid the starvation risk a naive fixed-priority scheme would have.

## Key takeaways

- Priority scheduling always favors the highest-priority ready process, either preemptively or non-preemptively.
- Without a fix, low-priority processes risk starvation if higher-priority processes keep arriving.
- Aging (gradually increasing effective priority the longer a process waits) is the standard fix.
- Real schedulers, including Linux's, incorporate priority-like mechanisms with explicit safeguards against this exact starvation risk.

## Related

- [Previous: SRTF (Shortest Remaining Time First) Scheduling](https://devsunite.com/resources/core-subjects/operating-systems/srtf-scheduling)
- [Next: Round Robin Scheduling](https://devsunite.com/resources/core-subjects/operating-systems/round-robin-scheduling)
- [More in Process Scheduling: Process Scheduling](https://devsunite.com/resources/core-subjects/operating-systems/process-scheduling)
- [More in Process Scheduling: Scheduling Queues](https://devsunite.com/resources/core-subjects/operating-systems/scheduling-queues)
- [More in Process Scheduling: Preemptive vs Non-Preemptive Scheduling](https://devsunite.com/resources/core-subjects/operating-systems/preemptive-vs-non-preemptive-scheduling)
- [More in Process Scheduling: Scheduler vs Dispatcher](https://devsunite.com/resources/core-subjects/operating-systems/scheduler-vs-dispatcher)
- [More in Process Scheduling: Scheduling Criteria](https://devsunite.com/resources/core-subjects/operating-systems/scheduling-criterias)
- [More in Process Scheduling: FCFS (First Come First Served) Scheduling](https://devsunite.com/resources/core-subjects/operating-systems/fcfs-scheduling)
- [More in Process Scheduling: Shortest Job First (SJF) Scheduling](https://devsunite.com/resources/core-subjects/operating-systems/sjf-scheduling)
- [More in Process Scheduling: Multilevel Queue Scheduling](https://devsunite.com/resources/core-subjects/operating-systems/multilevel-queue-scheduling)
- [More in Process Scheduling: Multilevel Feedback Queue Scheduling](https://devsunite.com/resources/core-subjects/operating-systems/multilevel-feedback-queue-scheduling)
- [More in Process Scheduling: Starvation and Aging in Scheduling](https://devsunite.com/resources/core-subjects/operating-systems/starvation-and-aging)
- [All 205 OS interview questions](https://devsunite.com/resources/core-subjects/operating-systems)
