What is Starvation in CPU Scheduling?
Learn what starvation is in OS scheduling, how it differs from deadlock, and how aging fixes it, with interview questions.
Expected Interview Answer
Starvation is a scheduling failure where a process is repeatedly passed over in favor of other processes and, as a result, waits indefinitely and may never get to run, even though the system as a whole keeps making progress.
Starvation typically arises under priority scheduling: if higher-priority processes keep arriving, a low-priority process can be pushed back in the ready queue every time the scheduler picks a new task, so it never reaches the front even though it is perfectly runnable. Unlike deadlock, where multiple processes are mutually blocked and none can proceed, starvation affects one or a few unlucky processes while the rest of the system continues functioning normally, which makes it harder to detect since overall throughput can look healthy. The standard fix is aging: the scheduler gradually increases the priority of a process the longer it waits, guaranteeing that even the lowest-priority process eventually becomes the highest-priority one and gets scheduled. Aging trades a small amount of strict priority ordering for the guarantee that no process waits forever, which is the correctness property most production schedulers require.
- Distinguishes starvation from deadlock precisely
- Explains why pure priority scheduling is dangerous without safeguards
- Introduces aging as the standard, provably fair mitigation
- Tests whether a candidate can reason about fairness guarantees
AI Mentor Explanation
Starvation is like a net-bowler who keeps getting bumped from the batting order because more in-form players keep arriving at practice, so despite being ready and available every single day, they never actually get a turn to bat. The fix is a coach enforcing a rule that anyone waiting more than a set number of sessions must be given the next turn regardless of form, which is exactly what aging does by raising priority the longer someone waits.
Step-by-Step Explanation
Step 1
Priority-based selection
The scheduler always picks the highest-priority ready process, ignoring how long lower-priority ones have waited.
Step 2
Continuous high-priority arrivals
New high-priority processes keep entering the ready queue faster than the low-priority one can be scheduled.
Step 3
Indefinite postponement
The low-priority process remains ready but is never selected, so its waiting time grows without bound.
Step 4
Aging mitigation
The scheduler gradually raises the waiting process’s priority over time until it eventually outranks the others and runs.
What Interviewer Expects
- A precise definition: indefinite postponement of a ready process
- A clear distinction between starvation and deadlock
- Aging as the standard fix, with a description of how it works
- Recognition that starvation can occur even while system throughput looks fine
Common Mistakes
- Confusing starvation with deadlock
- Claiming starvation can only happen with priority scheduling and nothing else
- Forgetting that aging is the standard, provably correct mitigation
- Assuming high system throughput rules out starvation for individual processes
Best Answer (HR Friendly)
“Starvation is when a task keeps getting skipped over in favor of other, seemingly more important tasks, and ends up waiting so long it might never actually run, even though the rest of the system is working fine. It usually happens with strict priority-based scheduling, and the standard fix, called aging, is to gradually boost a waiting task’s priority the longer it sits unserved so it eventually gets its turn.”
Code Example
struct process {
int base_priority; /* lower number = higher priority */
int wait_ticks;
};
#define AGING_STEP 1
#define AGING_INTERVAL 5 /* boost priority every 5 ticks waited */
int effective_priority(struct process *p) {
int boost = (p->wait_ticks / AGING_INTERVAL) * AGING_STEP;
int effective = p->base_priority - boost; /* lower is still better */
return (effective < 0) ? 0 : effective;
}
void tick_wait(struct process *p) {
p->wait_ticks++; /* called each scheduling cycle the process is not run */
}Follow-up Questions
- How is starvation different from deadlock?
- How does aging guarantee a starved process eventually runs?
- Can Round Robin cause starvation? Why or why not?
- What real-world subsystem, like disk I/O scheduling, is also vulnerable to starvation?
MCQ Practice
1. Starvation in scheduling refers to?
Starvation is when a runnable process keeps losing out to others and may wait indefinitely, distinct from deadlock’s mutual blocking.
2. What technique is the standard fix for starvation?
Aging guarantees fairness by boosting a process’s priority the longer it waits, ensuring it eventually becomes highest priority.
3. How does starvation differ from deadlock?
In starvation, the system as a whole keeps making progress except for the neglected process; in deadlock, all involved processes are mutually stuck.
Flash Cards
What is starvation? — A ready process is indefinitely postponed and may never get scheduled.
Starvation vs deadlock? — Starvation affects one process while the system progresses; deadlock halts all involved processes mutually.
What fixes starvation? — Aging — gradually raising a waiting process’s priority until it is eventually scheduled.
Which scheduling policy is most prone to starvation? — Strict priority scheduling without aging.