liveBook · Manning

Modification order

As explained in Modern C

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

For an atomic object, modification order is the single order of all its modifications that remains consistent with each participating thread’s sequenced-before order. Every thread dealing with that object perceives its changes consistently with this order. TAKEAWAY: modification order is local to one atomic object; it is not automatically one global order for every atomic object. section 19.1 section 19.3

One atomic object, six modifications

Consider atomic x with an initial value of 11, two increments, and three assignments. These six modifications form x’s modification order. Threads A and B must each perceive those changes in an order consistent with it, even when they perform the operations concurrently. An atomic read that observes a value written by another thread can establish synchronization between the threads. section 19.1 section 19.1

Keep these distinctions in view:

  • Modification order applies to modifications of the same atomic object and must respect each thread’s sequenced-before relation for those modifications. section 19.1
  • Sequential consistency adds a single global modification order for sequentially consistent operations, including operations on different atomic objects. section 19.3
  • Sequential consistency also enforces acquire-release semantics, but its stronger total ordering can constrain parallel execution. section 19.3

How Modern C covers it

How deep it goes
Defines the per-object order, illustrates six modifications, and contrasts it with sequential consistency’s global order across atomic objects.
Examples
Uses atomic x with initialization to 11, two increments, three assignments, and cross-thread reads that establish synchronization.
What it assumes
Assumes atomic objects, threads, and sequenced-before ordering; introduces synchronization through atomic reads and writes.
What you can do after
Evaluate whether atomic operations require per-object ordering or sequentially consistent global ordering.
How it connects
Connects atomic objects with sequenced-before, synchronization, acquire-release consistency, happened-before, 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. The section links point to the parts of the book it draws on.