Skip to main content
PRISM

Memory barriers

advanced · occasionally asked

The same program with a fence between the write and the read. The outcome that no ordering could explain becomes unreachable again.

Enumerating the interleavings

What this shows

A barrier does not make anything atomic. It forces publication, which is a different guarantee and the one the reordering was violating.

Why it is asked

The mechanism under every synchronisation primitive you use, and the reason a correct-looking double-checked lock was broken for a decade.

In an interview

The mechanism under every synchronisation primitive you use, and the reason a correct-looking double-checked lock was broken for a decade.

  • fences
  • happens-before
  • volatile
  • reordering

Run these next

The rest of memory and hardware