Designing an SPSC Lock free queue
summary
A concrete design surfaces: a working SPSC lock-free queue implemented with atomic head/tail indices, wraparound via power-of-two capacity (capacity = 2^N) and guarded against false sharing by 64-byte alignment. The page lists both blocking push/pop (mutex + condition_variable) and nonblocking try_push/try_pop using atomic loads/stores with acquire/release ordering and CAS where needed; examples show the head/tail increment logic and that the bounded circular buffer behaves correctly under single-producer single-consumer conditions.
AI-written summary · about
chapters (9)
- 0:00Lock-free queues intro
- 1:45Threads vs processes in C++
- 9:19Thread creation in C++
- 15:53Race conditions and mutex
- 21:37Deadlocks and livelocks
- 29:37Producer-consumer problem
- 36:05Thread-safe queue design
- 45:41Lock-free queue implementation
- 56:43Q&A
related talks
59mLock-free by Example
01h 00mLock-Free Programming (or, Juggling Razor Blades), Part I
01h 02mA Lock-Free Atomic Shared Pointer in Modern Cpp
01h 05mIntroduction to Wait-free Algorithms in C++ Programming
01h 04mConcurrency TS2: Improved C++ Concurrency and Lock-free Programming
59mMultithreading 101: Concurrency Primitives From Scratch
01h 04mThe C++20 Synchronization Library
01h 04m[old version]The C++20 Synchrononization Library
