Atomicity without ordering
The weakest useful atomic is relaxed ordering. A relaxed operation is still indivisible, so no torn read or lost update occurs, but it places no ordering constraints on surrounding memory accesses.
What it does and does not promise
- It guarantees the operation itself is atomic.
- It guarantees a single modification order per location, so all threads agree on the sequence of values that one variable took.
- It does not create any happens before edge with other variables.
Where it fits
Relaxed is right when you need a correct atomic value but not a synchronization point. A classic case is an event counter incremented from many threads where only the final total matters and nothing else depends on ordering. Using relaxed there avoids paying for fences you do not need.
The danger is using relaxed when you actually rely on ordering. Because it publishes nothing about other writes, a reader may see the atomic update yet miss data the writer produced beside it.
Key idea
Relaxed ordering keeps an operation atomic and per location consistent but adds no ordering with other accesses, making it ideal only for counters and similar order free updates.