liveBook · Manning

Livelock

As explained in Modern C, Third Edition

A livelock is a concurrency failure in which threads continue executing but repeatedly make no effective progress in response to one another.

A livelock is a concurrency failure in which threads keep executing but make no effective progress. At least two threads repeat a control-loop state independently of external input, so the program appears active while its work never advances. section 20.7

Detours that never escape

Imagine a vehicle entering a city block whose detours form a cycle. Each turn seems reasonable and traffic continues moving, but the vehicle circles forever. With multiple vehicles, changing arrival order, speed, or route can produce more complicated cycles that remain difficult to detect and prevent. section 15.4

Distinguish livelock from related threaded failures:

  • Deadlock leaves threads blocked while waiting for locks or conditions; livelock leaves threads running through a repeating control loop. section 20.7
  • Livelock prevention and detection require analyzing interactions among components, because threads may change order or route without escaping the cycle. section 15.4
  • Proving that a practical threaded program has no livelock requires a case analysis of its possible state progression. section 15.4
Figure 15.1 A configuration potentially leading to a livelock
figure

Use the configuration diagram to visualize how individually sensible detours can combine into a cyclic trap. section 15.4

How Modern C, Third Edition covers it

How deep it goes
Defines repeating control-loop behavior, contrasts it with deadlock, and points toward case analysis without developing a full prevention method.
Examples
Uses cyclic traffic detours and interacting vehicles to model threads that repeatedly change behavior without escaping.
What it assumes
Builds from basic threaded execution and deadlock, while defining livelock through comparison and analogy.
What you can do after
Evaluate threaded behavior by distinguishing blocked waits from active repetition and by analyzing possible state cycles.
How it connects
Connects livelock with threads, concurrency, deadlock, mutexes, condition variables, and program liveness.

Also explained in

Compare how 3 books explain livelock →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.