Acquire and Release Ordering

Use an atomic publication flag to carry an earlier result to a consumer under the language’s synchronization rules.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. A release publishes earlier actions to a matching acquire
  2. Repeated phases need an identity for each publication

A release publishes earlier actions to a matching acquire

In the simple single-publication pattern, a producer writes an ordinary result, then stores true to an atomic flag with release semantics. A consumer loads the flag with acquire semantics. If it observes that published value from the corresponding store, the release synchronizes with the acquire under the model. The write to the result then happens before the consumer reads it. A consumer seeing the initial false value has no such permission to read that result.

Repeated phases need an identity for each publication

Reusing the same flag value for several generations can obscure which writes a reader may rely on. The buffer lifetime and phase protocol must supply the additional invariant. A relaxed operation may be atomic without creating this ordering edge. Happens-before explains the transitive argument. Weak memory models examine the broader language and hardware contracts.[1][2]

References

  1. ISO C++ Working Draft, Order and Consistency ↩
  2. ISO C++ Working Draft, Multi-Threaded Executions and Data Races ↩