IT lexicon › Programming › Full fence

Full fence

Programming På svenska → Updated: 2026-11-15

A memory barrier that prevents both earlier and later instructions from reordering across this point.

A full fence (or total fence) is the strongest memory barrier. It says everything before this point must execute first, and everything after must execute after. It enforces a total order, necessary to implement sequential consistency. Full fences are expensive: they force the processor to drain buffers, wait for pending operations, and abandon much of its optimization capability.

In C++, this is `std::atomic_thread_fence(memory_order_seq_cst)` or an explicit `mfence` instruction on x86. They're used sparingly, only at critical synchronization points, because the cost exceeds acquire-release barriers.

← Back to the lexicon