← Lessons

quiz vs the machine

Gold1480

Concurrency

The Acquire Release Deep Dive

How paired one directional barriers create cheap, precise synchronization.

6 min read · core · beat Gold to climb

One directional ordering

Acquire and release are the workhorse memory orders. They are cheaper than full sequential consistency because each constrains reordering in only one direction, yet together they create the happens before edge you need.

What each side does

  • An acquire load prevents later reads and writes in program order from moving before it. Nothing after the acquire leaks above it.
  • A release store prevents earlier reads and writes from moving after it. Nothing before the release leaks below it.
  • When an acquire load reads the value written by a release store, the two synchronize with each other.

The classic pattern

A producer fills a buffer, then does a release store to a ready flag. The consumer does an acquire load of the flag, and once it sees ready, all the producer's earlier writes are guaranteed visible. The data does not need to be atomic itself, only the flag, because the happens before edge carries everything before the release.

Key idea

Acquire release uses one directional barriers that pair when a load reads a store, giving cheaper synchronization than seq cst while still establishing happens before.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a release store prevent?

2. When does an acquire load synchronize with a release store?