Multithreading 101: Concurrency Primitives From Scratch
summary
Builds concrete locking primitives: a simple spinlock using an atomic exchange spin loop (fast uncontended, wastes CPU when contended), then a kernel-assisted path using Linux futex and Windows WaitOnAddress via a futex/waitonaddress wrapper, and a portable parking lot with 4096 buckets that emulates futex semantics. Combines spin-then-park into a fast mutex (spin limit ≈1000, yield then park) and implements a condition variable on top; implementation runs and matches expected performance tradeoffs.
AI-written summary · about
chapters (7)
- 0:00Introduction to concurrency
- 2:47Implementing a spin lock
- 8:50Understanding futexes
- 14:17Platform-specific futexes
- 23:24Building the parking lot
- 44:57Creating a fast mutex
- 55:04Condition variables
related talks
52mBest Practices for Concurrency
59mThreads and Locks must Go
01h 07mAn Introduction to Multithreading in C++20
01h 00mLock-Free Programming (or, Juggling Razor Blades), Part I
01h 05mLet's write an async runtime
01h 04mConcurrency TS2: Improved C++ Concurrency and Lock-free Programming
01h 05mIntroduction to Wait-free Algorithms in C++ Programming
56mThe C++ Execution Model
