liveBook · Manning

Linearizability

As explained in Modern C, Third Edition

Linearizability is a concurrency correctness property under which each operation appears to take effect instantaneously at a point consistent with the ordering observed by threads.

Linearizability makes an operation on shared state appear indivisible and places it in an ordering that threads can observe consistently. For atomic objects, this means one thread can reason about another thread’s completed update instead of treating the access as an interleaved sequence. If a thread observes finished set to true, it can rely on the publishing thread having performed its required preceding actions. section 20.1

Publishing completion with an atomic flag

A shared life simulation declares communication fields with _Atomic, including _Atomic(bool) finished. One thread updates the simulation and sets finished; another observes the flag. Linearizability lets the observer reason about the update as an ordered event rather than an unsynchronized race. section 20.1

  // Parameters that will dynamically be changed by
  // different threads
  _Atomic(size_t) constellations; //< Constellations visited
  _Atomic(size_t) x0;             //< Cursor position, row
  _Atomic(size_t) x1;             //< Cursor position, column
  _Atomic(size_t) frames;         //< FPS for display
  _Atomic(bool)   finished;       //< This game is finished.

These atomic fields show the shared state whose individual accesses receive linearizable treatment. section 20.1

Linearizability also governs mutex-protected critical sections:

  • A mutex lock blocks until the calling thread can enter the protected section. section 20.4
  • After acquiring a mutex, a thread can rely on operations completed before another thread released that same mutex. section 20.4
  • Mutexes protect compound updates such as forcing a 3×3 cell birth, while other accesses use atomic objects. section 20.4

How Modern C, Third Edition covers it

How deep it goes
Defines indivisibility and observable ordering, then applies them to atomic fields and mutexes without formalizing happened-before.
Examples
Uses atomic simulation fields, a finished flag, cursor state, and a mutex-protected 3×3 cell-birth operation.
What it assumes
Assumes familiarity with C threads and shared objects while introducing atomic declarations, mutex operations, and critical sections.
What you can do after
Evaluate concurrent updates by identifying atomic operations and mutex boundaries that establish indivisible, observable ordering.
How it connects
Connects atomic objects, mutexes, critical sections, race conditions, sequencing, and the happened-before relation.

Also explained in

Compare how 4 books explain linearizability →

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.