Atomics, Memory Ordering & Lock-Free
Studies in this cluster, in series order. Each one keeps its own URL.
Concurrency
Locks, isolation, and the bugs that only show up in production.
Atomics, Memory Ordering & Lock-Free
6 studies- 1.Atomics, Memory Ordering & Lock-Free — Races, Barriers & When Locks WinInterview map for process-local concurrency: data races versus race conditions, atomics and CAS, memory orders, lock-free structures and ABA, and when a mutex still wins.
- 2.Data Races & Happens-Before — UB, Tools & Mental ModelsA data race is conflicting access with no happens-before edge. C++ and Rust call that undefined behavior. This page is the definition, the edges, and the tools that catch it.
- 3.Atomic Operations & CAS Loops — Progress GuaranteesAtomics are indivisible read-modify-write on one word. CAS loops build lock-free algorithms and accidental spinlocks. This page is the operations, the retry shape, and the progress words.
- 4.Memory Ordering — Relaxed, Acquire/Release, SeqCstAtomicity stops a torn word. Memory order controls which other accesses may move around that word. Relaxed, acquire/release, and seq_cst are the ladder, and a publish flag is the pattern to know.
- 5.Lock-Free Structures — Queues, Stacks & ABALock-free structures use CAS so some thread always makes progress. The teaching cases are the Treiber stack, the Michael-Scott queue, and an SPSC ring. ABA and reclamation are the part people skip.
- 6.When Locks Win — Contention, Fairness & Hybrid DesignsA short mutex often beats a CAS storm on one cache line. Locks cover multi-field invariants, fairness, and review. This page is when to keep them, when to shard, and when a hybrid is honest.