Starvation

기아 상태

One job makes no progress because other jobs repeatedly take a needed resource.

···
html
<div class="v"><header><b>STARVATION</b><span id="state"></span></header><main><div class="queue"><div class="arrival" id="arrival"></div><div class="low" id="low">LOW PRIORITY · waiting</div><div class="cpu" id="cpu"></div></div></main><footer>high priority keeps winning</footer></div>
css
.v{width:min(92vw,660px);height:min(86vh,310px);box-sizing:border-box;padding:clamp(9px,2.5vmin,18px);border:1px solid var(--line);border-radius:14px;background:var(--surface);display:flex;flex-direction:column;gap:7px;color:var(--fg);font:500 clamp(15px,3.2vmin,17px)/1.25 var(--font-sans, sans-serif)}.v header,.v footer{display:flex;justify-content:space-between;align-items:center;gap:8px;white-space:nowrap}.v header b{color:var(--accent);font-size:.9em}.v header span,.v footer{color:var(--muted);font-size:.82em}.v main{flex:1;min-height:0;position:relative;overflow:hidden}.v .mono{font-family:ui-monospace,SFMono-Regular,Consolas,monospace}.v .active{background:var(--accent)!important;color:var(--bg)!important;border-color:var(--accent)!important}.v .muted{opacity:.28} .queue{height:100%;display:flex;flex-direction:column;justify-content:center;gap:8px}.arrival{display:flex;gap:4px;min-height:36px}.arrival b{flex:1;max-width:23%;border:1px solid var(--line);border-radius:5px;display:grid;place-items:center;font:600 clamp(12px,2.7vmin,16px) var(--font-sans, sans-serif)}.low,.cpu{border:1px solid var(--line);border-radius:5px;padding:6px;text-align:center;font:600 clamp(12px,2.7vmin,16px) var(--font-sans, sans-serif)}.low{color:var(--accent-2)}.cpu{color:var(--accent)}
js
let n=0;function draw(){const count=n+1;document.getElementById("arrival").innerHTML=Array.from({length:count},(_,i)=>"<b>H"+(i+1)+"</b>").join("");document.getElementById("low").textContent="LOW PRIORITY · waits "+count+" turns";document.getElementById("cpu").textContent="CPU → H"+count;document.getElementById("state").textContent="turn "+count;n=(n+1)%4}draw();setInterval(draw,900)

With starvation, the system still runs but one job cannot regularly obtain a shared resource or execution time. A continuous stream of higher-priority work can keep a lower-priority job waiting.

Other jobs make progress, unlike a deadlock. Fair queues, priority aging, and shorter critical sections can bound the wait. The demo shows repeated high-priority arrivals delaying a low-priority job.

When to use

Use it when a subset of jobs waits unusually long in a priority queue or lock.

Open as page ↗