liveBook · Manning

Modification order

As explained in Modern C, Third Edition

Modification order is the total order of modifications to a particular atomic object that is consistent with each participating thread's sequenced-before order.

Modification order is the total order of modifications to one atomic object. It must agree with the sequenced-before order of every thread that modifies or observes that object, so threads perceive its changes consistently. section 21.1

One atomic object, one modification order

For _Atomic(unsigned) x = 11, operations such as ++x, x = 31, x--, x = 5, and x = 0 form modifications of x. A valid modification order places all of them in one order while preserving each thread's local sequenced-before relationships. Reads can synchronize threads when they observe values written by another thread. section 21.1

Figure 21.1 Two threads that synchronize via an atomic. The circles present the modifications of object x. The bars below the threads represent information about the state of A, and those above represent information about the state of B.
figure

Use the thread diagram to track the six modifications of x and the synchronization points created when threads read one another's atomic writes. section 21.1

Keep these distinctions in view:

  • A modification order belongs to one atomic object; it does not automatically impose one order across different atomic objects. section 21.1 section 21.3
  • Sequential consistency strengthens the rule by requiring all sequentially consistent operations, even on different atomic objects, to fit one global modification order. section 21.3

How Modern C, Third Edition covers it

How deep it goes
Defines per-object ordering and contrasts it with sequential consistency, but does not develop a full formal memory-model derivation.
Examples
Uses a shared atomic x initialized to 11, threaded increments, decrements, assignments, reads, and a synchronization diagram.
What it assumes
Assumes familiarity with threads, atomic operations, and sequenced-before ordering while explaining their synchronization relationship.
What you can do after
Evaluate/understand how atomic reads and writes can be ordered consistently and when stronger global ordering is required.
How it connects
Connects modification order with atomic objects, sequenced-before order, synchronization, happened-before relation, acquire-release consistency, and sequential consistency.

Also explained in

Compare how 3 books explain modification order →

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.