Safety: off --- How not to shoot yourself in the foot with C++ atomics
summary
Explains concrete C++ atomics behavior: which std::atomic operations exist, compare_exchange_weak vs strong, memory orders (seq_cst, acquire/release, relaxed) and when they synchronize, and that atomic_flag is the only guaranteed lock‑free type. Builds and analyzes lock‑free queues and stacks: a single‑producer single‑consumer ring works, naive multi‑producer ring fails (data race), a linked‑list push/pop fix yields obstruction‑free behavior, ABA appears on pop and is fixed with a tag or hazard pointers. Recommends profile before/after and test on ARM/Power.
AI-written summary · about
chapters (4)
related talks
01h 03mUsing weakly ordered C++ atomics correctly
01h 14m“C++ atomics, from basic to advanced. What do they really do?”
01h 01m“C++11/14/17 atomics and memory model..."
01h 11mLock-Free Programming (or, Juggling Razor Blades), Part II
22mWhat we learned from C++ atomics and memory model standardization
01h 00mConcurrency in C++20: A Deep Dive
01h 28mAtomic’s memory orders, what for?
01h 22mBeyond Sequential Consistency - Leveraging Atomics for Fun & Profit
