C++ Memory Model: from C++11 to C++23
summary
Covers concrete changes since C++11 with code and disassembly showing where naive code breaks and what actually works: examples where memory_order_relaxed fails and acquire/release fences fix it, x86 and RISC‑V assembly that proves the compiler emitted atomic instructions, spinlock and compare_exchange examples, microbenchmarks showing std::jthread performance similar to pthreads, and new C++20/C++23 tools like std::jthread and stop_token and std::atomic<std::shared_ptr> with notes about lock‑free vs locked implementations.
AI-written summary · about
chapters (19)
- 0:00Introduction
- 2:13Processor execution vs program
- 3:17Compiler optimizations
- 8:12CPU out-of-order execution
- 15:13C++ memory model
- 18:49Sequential consistency
- 22:19Volatile not for sync
- 24:48Memory barriers
- 28:43C++11 threading tools
- 32:53Atomic operations
- 35:48Atomic performance
- 38:15C++20 atomic shared pointers
- 39:00Futures and promises
- 41:30C++20 jthread
- 43:17Latches and barriers
- 48:15Static initialization
- 51:25Lazy threads
- 52:48Atomic usage
- 56:24Q&A








