liveBook · Manning

Starvation

As explained in Grokking Concurrency

Starvation is a concurrency failure in which a task is indefinitely denied the resources or execution opportunities needed to make progress.

Imagine several people reaching for a shared plate while the quickest person repeatedly takes the food first. The others remain ready but never get a fair chance. section 9.6

Starvation is a concurrency failure in which a thread or task is indefinitely denied CPU time or shared resources. Because it cannot obtain what it needs, its work makes no progress. section 9.11 section 9.6

Philosophers and chopsticks

In a dining-philosophers program, one philosopher repeatedly acquires both chopstick locks before others can obtain theirs. One philosopher eats 417 dumplings while several eat none, showing how repeated lock preference can starve threads. section 9.6

Recognize starvation through its causes and possible remedies:

  • Identify greedy threads that repeatedly hold or reacquire a shared resource. section 9.6
  • Check scheduling algorithms, synchronization, excessive task counts, and priority differences; low-priority tasks may wait indefinitely. section 9.11 section 9.6
  • Consider priority queuing with aging so waiting tasks are not constantly blocked. section 9.6
  • Distinguish starvation from deadlock, where tasks wait on one another, and livelock, where tasks keep running without completing work. section 9.11

How Grokking Concurrency covers it

How deep it goes
Explains resource denial, scheduling causes, priority effects, and aging, but does not detail an implementation of fair scheduling.
Examples
Uses dining philosophers, chopstick locks, dumpling counts, and unequal philosopher output to demonstrate unfair progress.
What it assumes
Assumes basic concurrency and synchronization primitives while contrasting starvation with deadlock and livelock.
What you can do after
Diagnose starvation by tracing resource access, scheduling, priorities, synchronization, and task load.
How it connects
Connects starvation with deadlock, livelock, synchronization, scheduling algorithms, priority queuing, aging, and denial-of-service attacks.

Also explained in

Compare how 4 books explain starvation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Concurrency. The section links point to the parts of the book it draws on.