The Memory Model in C++
summary
Covers the C++ memory model focusing on which atomic primitives and memory orders are useful: compare_exchange, test_and_set spinlocks, acquire/release for publishing pointers, and relaxed for counters, noting memory_order_consume is effectively unimplemented. Implements and benchmarks patterns (singleton, static-pointer variant) with tens of millions of iterations to show seq_cst is much slower under contention, acquire/release enables lock-free patterns to beat heavy locks, and explains why double-checked locking can fail.
AI-written summary · about
chapters (13)
- 0:00Start
- 0:58Multithreading with C++
- 2:05Expert Levels
- 3:15The Contract
- 8:43Atomics: std::atomic_flag
- 11:30Atomics: std::atomic<bool>
- 12:57Atomics: Condition Variable
- 19:12Synchronization and Ordering
- 39:45Sequential Consistency
- 41:13Acquire-Release Semantic
- 41:43Meyers Singleton
- 46:22Singleton: The Performance Test
- 47:39The C++ Memory Model
related talks
59mC++ Memory Model: from C++11 to C++23
01h 01mThe two memory models
56mThe C++ Execution Model
41mUnderstanding 5 languages memory models (or most of them)
01h 02mA Lock-Free Atomic Shared Pointer in Modern Cpp
39mRust Atomics in the Wild: Memory Ordering Design Patterns [...]
01h 05mIntroduction to Wait-free Algorithms in C++ Programming
58mUnderstanding and Mastering C++'s Complexity
