Starvation in Operating Systems

Starvation is a condition where a process is repeatedly denied a resource it needs because other processes keep getting priority, even though the resource does become available to others. Unlike a deadlock, there is no permanent standstill: the starving process could eventually run, but it keeps being passed over, most commonly under priority-based scheduling or allocation.

3 min read

Starvation is a process being perpetually denied access to a resource it needs, even though the resource does eventually become available for others. Unlike a deadlock, there's no permanent structural standstill, the process is theoretically able to eventually run; it just keeps getting passed over.

How starvation actually happens

The most common cause is a priority-based scheduling or resource-allocation scheme where lower-priority requests are only served once there are no higher-priority requests pending. If high-priority requests keep arriving continuously, a low-priority request can wait indefinitely, not because it's blocked in a cycle, but because it's always last in line.

A worked example

Imagine a priority scheduler where a lower number means higher priority, and the scheduler always picks the lowest-priority-number process currently ready.

  • P1 arrives with priority 5 (low importance).
  • While P1 waits, P2 arrives with priority 1, runs, finishes.
  • Then P3 arrives with priority 2, runs, finishes.
  • Then P4 arrives with priority 1 again, runs, finishes.

As long as processes with a lower priority number than 5 keep showing up, P1 never gets scheduled. If this pattern continues indefinitely, P1 starves, not deadlocked, just perpetually deprioritized.

The standard fix: aging

Aging solves starvation by gradually increasing a waiting process's effective priority the longer it waits, until it eventually becomes high enough priority to be scheduled regardless of what else arrives. In the example above, if P1's priority number decreased by 1 for every unit of time it waited, it would eventually reach priority 1 itself and get scheduled, guaranteeing it can't wait forever.

Where this matters in real systems

Real-world priority queues and job schedulers almost always need some form of aging or a fairness guarantee, because a pure strict-priority scheme is a starvation risk by construction. Linux's Completely Fair Scheduler, despite its name being about a different scheduling philosophy than aging specifically, is fundamentally designed around the same underlying concern: making sure no runnable process gets starved of CPU time indefinitely, by tracking how much virtual runtime each process has accumulated and always favoring whichever process has received the least CPU time relative to its fair share.

What interviewers actually ask about starvation

  • "What's the difference between starvation and deadlock?" A deadlock is a permanent standstill where progress is structurally impossible without intervention; starvation is a process being repeatedly denied a resource it could theoretically still eventually get, just never actually does in practice.
  • "How do you fix starvation?" Aging, gradually increasing the effective priority of a waiting process the longer it waits.
  • "Can a system have starvation without ever having a deadlock?" Yes, these are independent problems, a purely priority-based scheduler with no cycles at all can still starve a low-priority process indefinitely.
  • "Give a real-world example of a starvation risk." A strict priority queue for CPU scheduling, or a lock implementation that always grants access to whichever thread requested most recently rather than whichever has waited longest.

Key takeaways

  • Starvation is repeated, indefinite denial of a resource, distinct from a deadlock's permanent structural standstill.
  • It typically arises from strict priority schemes that keep favoring newer or higher-priority requests.
  • Aging, gradually raising a waiting process's effective priority, is the standard fix.
  • Real schedulers, including Linux's CFS, are explicitly designed with fairness guarantees to avoid this exact problem.
All 205 OS interview questions

Browse all Operating Systems topics

Log in to save which topics you've read across every subject.

Frequently asked questions

What's the difference between starvation and deadlock?

A deadlock is a permanent standstill where progress is structurally impossible without intervention; starvation is a process being repeatedly denied a resource it could theoretically still eventually get, just never actually does in practice.

How do you fix starvation?

Aging, gradually increasing the effective priority of a waiting process the longer it waits.

Can a system have starvation without ever having a deadlock?

Yes, these are independent problems, a purely priority-based scheduler with no cycles at all can still starve a low-priority process indefinitely.

Give a real-world example of a starvation risk.

A strict priority queue for CPU scheduling, or a lock implementation that always grants access to whichever thread requested most recently rather than whichever has waited longest.