Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Additional Resources

C++ atomics, from basic to advanced. What do they really do? by Fedor Pikus, an hour-long talk on this topic.

How to Make a Multiprocessor Computer That Correctly Executes Multiprocess Programs, Leslie Lamport’s classic paper introducing sequential consistency.

x86-TSO: A Rigorous and Usable Programmer’s Model for x86 Multiprocessors, by Peter Sewell et al., for a precise description of the x86 memory model.

Hardware Memory Models, by Russ Cox, the essay whose SC/TSO/relaxed progression and litmus tests this chapter’s “Memory consistency models” section is adapted from.

atomic<> Weapons: The C++11 Memory Model and Modern Hardware by Herb Sutter, a three-hour talk that provides a deeper dive. Also the source of the idealized multi-core processor and memory hierarchy figures.

Futexes are Tricky, a paper by Ulrich Drepper on how mutexes and other synchronization primitives can be built in Linux using atomic operations and syscalls.

Is Parallel Programming Hard, And, If So, What Can You Do About It?, by Paul E. McKenney, an incredibly comprehensive book covering parallel data structures and algorithms, transactional memory, cache coherence protocols, CPU architecture specifics, and more.

Memory Barriers: a Hardware View for Software Hackers, an older but much shorter piece by McKenney explaining how memory barriers are implemented in the Linux kernel on various architectures.

diy, plus the related herdtools7 suite, for generating and checking litmus tests against hardware and language memory models.

Preshing On Programming, a blog with many excellent articles on lockless concurrency.

No Sane Compiler Would Optimize Atomics, a discussion of how atomic operations are handled by current optimizers. Available as a writeup, N4455, and as a CppCon talk.

cppreference.com, an excellent reference for the C and C++ memory model and atomic API.

Matt Godbolt’s Compiler Explorer, an online tool that provides live, color-coded disassembly using compilers and flags of your choosing. Fantastic for examining what compilers emit for various atomic operations on different architectures.