How do atomic fences establish synchronization, and why is a fence without an atomic rendezvous insufficient?
Show answer and explanation
A fence orders surrounding evaluations but inter-thread synchronization still needs atomic operations connected by a reads-from relationship. For fence-to-fence synchronization, a release fence is sequenced before an atomic write, an atomic read in the other thread reads that write or its permitted successor, and an acquire fence is sequenced after the read. Related fence-to-atomic and atomic-to-fence patterns have similarly precise requirements. Two standalone fences around ordinary conflicting accesses do not communicate, do not create synchronizes-with, and therefore do not remove the data race.
A fence orders surrounding evaluations but inter-thread synchronization still needs atomic operations connected by a reads-from relationship. For fence-to-fence synchronization, a release fence is sequenced before an atomic write, an atomic read in the other thread reads that write or its permitted successor, and an acquire fence is sequenced after the read. Related fence-to-atomic and atomic-to-fence patterns have similarly precise requirements. Two standalone fences around ordinary conflicting accesses do not communicate, do not create synchronizes-with, and therefore do not remove the data race.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.