Go Internals: sync.Mutex and sync/atomic — From Data Race to Starvation Mode

Mutex and atomic are not two independent tools — they are one stack of abstractions. I dig through the stack from data race to starvation mode: why x++ is three ARM64 instructions, how CAS became a universal primitive (Herlihy 1991), why Mutex is built on top of atomic CAS, and how Russ Cox’s barging-vs-handoff debate (issue #13086) gave Go its 1ms starvation threshold. With public benchmarks, the bit layout of Mutex state, and a cheatsheet for when to reach for which.

June 18, 2026 · 38 min · 7930 words · Sebastian PE