Memory Ordering Fence¶
A memory-ordering fence constrains selected memory operations around it according to a concurrency memory model.
Core Idea¶
A memory-ordering fence is a concurrency primitive that constrains how selected memory operations before and after a point relate under a specified memory model. Which operations are ordered, and what another thread can conclude, depend on the fence and on the surrounding operations. A write memory barrier is one specialized form; a full barrier, acquire fence and release fence have different contracts.[1][2]
How would you explain it like I'm…
The Don't-Swap Line
Order Rule for Shared Memory
Memory Ordering Barrier
Structural Signature¶
The roles are an executing thread or CPU, memory operations on either side, the fence and its ordering strength, the governing memory model, and the observations or synchronization that model permits. A constraint is meaningful only for the accesses and participants to which its contract applies.[1][2]
Examples¶
Linux write memory barrier. The Linux Kernel Memory Model describes WRITE_ONCE(x, 1); smp_wmb(); WRITE_ONCE(y, 1);: its write barrier orders the two marked writes in the documented model. The documentation warns that compiler transformations of unmarked C stores can defeat the intended ordering and often recommends a release store instead. This is an ordering claim, not a promise that every reader independently observes a consistent snapshot or that writes are durable on storage.[1]
C++ release and acquire fences. The C++ working draft specifies that a release fence can synchronize with an acquire fence when the specified intervening atomic operations access the same atomic object and satisfy the draft's reads-from condition. The fences alone, without those conditions, do not create that synchronization. A signal fence has a narrower scope between a thread and a signal handler executed in that thread.[2]
Boundaries and Use¶
A fence is not a storage cache flush and does not by itself make earlier writes durable. A garbage-collector write barrier instead performs collector bookkeeping around reference mutations. To reason about publication, identify both the publisher and reader operations, their synchronization relation and applicable memory model; a fence by itself does not repair a data race or specify a complete protocol.[1][2]
Neighborhood in Abstraction Space¶
Memory Ordering Fence sits in a sparse region of the domain-specific corpus (90th percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.
Family — Unclustered & Miscellaneous (3155 abstractions)
Nearest neighbors
- CPU Shielding — 0.79
- Release Consistency — 0.79
- Commander's-Intent Ambiguity — 0.78
- Segmentation Fault — 0.78
- Sequence Diagram — 0.78
Computed from structural-signature embeddings · 2026-11-14
References¶
[1] Linux kernel documentation, “Ordering,” Linux Kernel Memory Model, sections “Categories of Ordering” and “Write Memory Barrier,” https://docs.kernel.org/dev-tools/lkmm/docs/ordering.html. registry ↩a ↩b ↩c ↩d
[2] ISO C++ working draft, “Fences [atomics.fences],” https://eel.is/c++draft/atomics.fences, accessed for its stated draft synchronization rules. registry ↩a ↩b ↩c ↩d