Module 9: Concurrency

Threads, mutexes, race conditions

Lessons

IDTitleDuration
9-1Threads and pthreads30 min
9-2Mutexes and Race Conditions35 min
9-3Condition Variables30 min
9-4Atomic Operations25 min
9-5ThreadSanitizer and Debugging Races20 min

Project

| 9-proj | Project: Thread Pool with Work Queue | 75 min |

Key Concepts

threads, mutexes, atomics

PDF Status

  • PDF ch10 (Concurrency) — Complete (written 2026-04-08).
    • Key Concepts: pthread lifecycle, mutex patterns, condition variable monitor pattern, C11 atomics (_Atomic/stdatomic.h), deadlock/livelock/priority inversion.
    • Going Deeper: C11 memory model (happens-before, seq-cst vs acquire/release vs relaxed with worked example), condition variable pitfalls (spurious wakeups, lost wakeup race, broadcast vs signal), lock-free basics (CAS, ABA problem, atomics vs mutex decision table), TSan shadow memory mechanism and report anatomy.
    • Real-World Connection: CPython Python/ceval_gil.ctake_gil/drop_gil, relaxed atomic for drop_request on the hot path, GIL rationale and PEP 703.
    • Exercises 10.1–10.4 + fully annotated solutions + test files.