A synchronizes-with edge needs a release on one side and an acquire on the other. These are directional half-barriers, and their asymmetry is the whole trick:

  • Release (applies to a write): nothing before it in program order may be reordered after it. It publishes — everything the thread did before the release is finalised and made visible at the moment another thread observes this write.
  • Acquire (applies to a read): nothing after it in program order may be reordered before it. It subscribes — once it observes a released value, everything after it sees everything the releaser published.

Picture it: release is a floor (things above can’t fall through downward), acquire is a ceiling (things below can’t rise through upward). When an acquire observes the value written by a release, they click into a synchronizes-with edge, and transitivity carries every write-before-the-release into visibility-after-the-acquire:

Beyond plain acquire/release there are weaker and stronger orderings: relaxed gives atomicity only, no ordering/visibility (fine for a pure counter); seq_cst adds a single global total order all threads agree on, stronger and costlier than acquire/release alone.

See also

References

Questions

flashcards/stem/os

What is release semantics, and what is acquire semantics?::Release (on a write) forbids reordering earlier ops after it and publishes prior writes; acquire (on a read) forbids reordering later ops before it and observes what a matching release published

When do a release and an acquire form a synchronizes-with edge?::When the acquire read observes the value written by the release store — then everything before the release is visible after the acquire

Release is a floor (nothing before it moves after it); acquire is a ceiling (nothing after it moves before it).

memory_order_relaxed gives atomicity only (no ordering); seq_cst adds a single global total order all threads agree on.