The happens-before relation, written F → E, provides a partial ordering for reasoning about events across concurrent threads. It combines same-thread sequencing with cross-thread synchronization. section 21.1
Its ordering rules include:
- If F is sequenced before E in one thread, then F happens before E. section 21.1
- Atomic operations can synchronize threads when one thread writes a value and another reads that value. section 21.1
- Modifications of an atomic object follow a modification order consistent with each thread’s sequenced-before ordering. section 21.1
- Certain C library calls, including thrd_join and mtx_lock, also provide synchronization. section 21.0
Atomic modification order
An atomic object can connect operations performed by different threads: _Atomic(unsigned) x = 11; one thread may execute ++x and x = 31, while another may execute x--, x = 5, and read x. The possible modifications are arranged in an order consistent with each thread’s local sequencing. section 21.1
_Atomic(unsigned) x = 11;
Inspect the atomic declaration used to anchor the modification-order example. section 21.1




