🧠 What is Aging (or Ageing)?
Aging is a technique used in CPU scheduling to gradually increase the priority of waiting processes so that they eventually get the CPU and don’t starve.
🎯 Why Aging?
When a process has been waiting in the ready queue for too long, the system:
-
Boosts its priority periodically
-
This ensures that it doesn’t wait forever, even in a priority-based scheduling system
🧩 Example (Priority Scheduling without Aging)
| Time | Process | Priority (Lower is better) |
|---|---|---|
| 0 | P1 | 1 |
| 1 | P2 | 1 |
| 2 | P3 | 1 |
| 3 | P4 | 5 ← Low priority |
-
P4 may never run because new high-priority processes keep arriving
-
This is starvation
✅ With Aging
-
Every 5 seconds, increase P4’s priority by 1 step
-
Eventually:
P4 priority: 5 → 4 → 3 → 2 → 1 -
Now it competes fairly and gets CPU
⚙️ How It’s Implemented (Simple Pseudocode)
for process in ready_queue:
if process.wait_time > aging_threshold:
process.priority -= 1 # higher priority
-
aging_thresholdcan be tuned (e.g., 10 seconds) -
The lower the priority value, the sooner it gets CPU
🧠 Key Points
| Property | Value |
|---|---|
| 📦 Type | Dynamic priority adjustment |
| ✅ Prevents | Starvation in priority-based and SJF algorithms |
| 🧠 Common In | Multilevel Feedback Queues, Linux CFS |
| 🧪 Tradeoff | Slightly more complex scheduler, but fairer |
🧠 Interview-Ready Definition:
Aging is a technique used to prevent starvation by gradually increasing the priority of waiting processes in the ready queue. This ensures that even low-priority or long-duration jobs eventually get scheduled for CPU execution.
🧠 One-Liner for Interviews:
“Aging prevents starvation by slowly boosting a waiting process’s priority until it gets its fair turn.”
🖥️ Real-World Analogy
You’re at the end of a queue at a food stall.
Every 5 minutes, you’re allowed to move one position forward — even if VIPs keep arriving.
Eventually, you get your food — that’s aging.