liveBook · Manning

Liveness

As explained in Modern C, Third Edition

Liveness is the property that a concurrent program continues to make progress rather than becoming permanently blocked or stalled.

Liveness means that a concurrent program continues to make progress instead of becoming permanently blocked or stalled. Progress may appear as advancing state counters, terminating a computation, or reaching a new configuration. section 20.7

Detecting progress in B9

In B9, update_thread and account_thread alternate through their critical sections, incrementing L->iteration and L->accounted. If user input does not intervene, L->iteration advances until a termination condition is met or the counter reaches SIZE_MAX. Because the visible cell configuration might otherwise repeat indefinitely, life_update detects a previously seen configuration and finishes the game. section 20.7

TAKEAWAY rules:

  • Prove that relevant state changes advance toward termination or another demonstrable progress condition. section 20.7
  • Treat repeated visible states as possible livelock unless hidden state or an explicit termination test guarantees progress. section 20.7
  • Recognize that mutexes and condition variables can make liveness verification difficult in larger threaded programs. section 20.8
// thread A                            // thread B
mtx_lock(&M);..........................mtx_lock(&N);
mtx_lock(&N); /*waiting for B */       mtx_lock(&M); /*waiting for A */

A circular lock-acquisition pattern illustrates how threads can wait on one another instead of making progress. section 20.7

How Modern C, Third Edition covers it

How deep it goes
Builds a proof sketch around advancing counters and repeated configurations, while deferring the full difficulty of larger programs.
Examples
Uses B9’s alternating update threads, bounded counters, repeated cell configurations, and circular mutex acquisition.
What you can do after
Evaluate/understand progress arguments by tracking state advancement and identifying possible indefinite repetition or waiting.
How it connects
Connects liveness with mutexes, condition variables, critical sections, atomic data, termination conditions, and livelock.

Also explained in

Compare how 2 books explain liveness →

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.