Systems Programming · Cluster
Concurrency Primitives
Atomics, fences, and lock-free design.
- 01 Atomicity and Ordering Are Separate Guarantees in the C Memory Model Why making a shared object atomic removes lost updates but not stale reads, how the C memory model defines a data race, and what happens-before does and does not cover.
- 02 Compare-and-Swap and Why the Retry Loop Must Re-read How a conditional store becomes a universal synchronisation primitive, why weak compare-and-exchange may fail spuriously, and what makes a CAS loop terminate.
- 03 Acquire and Release: What Each Ordering Forbids The precise prohibitions that acquire and release each impose, why the pair cannot order a store against a later load, and when a standalone fence is the only option.
- 04 Cache Line Transfer, False Sharing, and the Cost of Contention Why an atomic operation on an uncontended location is cheap and on a contended one is not, what coherence protocol traffic each attempt generates, and how padding and sharding change the shape of the cost.
- 05 Spinlock Design from Test-and-Set to Ticket Locks How a test-and-set lock starves its waiters, why test-and-test-and-set helps, and how a ticket lock turns a race into a queue without a fairness guarantee.
- 06 Seqlocks: Consistent Reads Without Reader-Side Writes How an even/odd sequence counter lets readers detect a concurrent update, why the read side must be free of side effects, and what the retry cost looks like under write-heavy load.
- 07 The ABA Problem in Treiber Stacks Why a single compare-and-swap suffices to push onto a Treiber stack but not to pop from it, what the address comparison cannot detect, and which remedies actually close the window.
- 08 Memory Reclamation for Lock-Free Structures Hazard pointers, epoch-based reclamation, and reference counting compared by what they cost on the read path, when memory is actually returned, and which failure they tolerate.
- 09 Progress Guarantees and the Lock-Free Hierarchy The difference between obstruction-free, lock-free, and wait-free, why lock-free does not mean no locks, and how helping makes a single-word operation wait-free.
- 10 Litmus Tests and Store Buffering How a five-line litmus test distinguishes total store order from sequential consistency, why the x86 store buffer permits a forbidden outcome, and what each outcome costs to rule out.