Skip to content

Volume 5: Hands-On Labs ​

The exercises in Volume 5 come in three tiers, going from easier to harder and from individual building blocks to complete systems.

Tier one is made up of the small in-article exercises attached to the end of each article, which verify a single knowledge point — for example, recognizing a data race, predicate-based waiting on a condition_variable, or picking the right memory order for atomics. Each exercise takes 10–20 minutes and needs no extra project scaffolding.

Tier two is the chapter-scale assignments (Labs): the 8 labs listed on this page. Each lab is a runnable mini system broken into 3–5 milestones, and every milestone has a well-defined interface, Catch2 tests, and acceptance criteria. When you finish one, you should walk away with a reusable concurrency component, not a pile of scattered demos.

Tier three is the end-of-volume capstone project (Capstone), which wires the components from all the earlier labs together into a mini concurrent runtime.

Lab Overview ​

LabProject NameChapters CoveredSuggested TimeDifficultyPrerequisite Labs
Lab 0Thread Lifecyclech00–ch014–6hintermediateNone
Lab 1Bounded Queue & Sync Primitivesch02–ch048–12hintermediateLab 0
Lab 2Atomic Metrics & SPSC Ring Bufferch03–ch046–8hintermediateLab 0
Lab 2.5Concurrency Debuggingch083–4hintermediateLab 0–2
Lab 3Production-style Thread Poolch0510–14hadvancedLab 0–1
Lab 4Coroutine Scheduler & Event Loopch0612–16hadvancedLab 3
Lab 5Channel or Actor Runtimech078–12hadvancedLab 1, 4
CapstoneMini Concurrent Runtimech08–ch098–12hadvancedLab 0–5

The bare minimum — completing Lab 0, Lab 1, Lab 3, and the Capstone (about 30–45 hours) — already covers the core competency curve of Volume 5. Working through every lab in full takes roughly 60–85 hours.

Lab Dependencies ​

C++
Lab 0 (joining_thread / thread_guard)
  │
  ├─→ Lab 1 (BoundedBlockingQueue, ConcurrentCache)
  │     │
  │     ├─→ Lab 2 (SpscRingBuffer)        ─ independent implementation, does not depend on Lab 1
  │     │
  │     ├─→ Lab 2.5 (Debugging Lab)        ─ reuses code from Labs 0–2 as diagnostic material
  │     │
  │     └─→ Lab 3 (ThreadPool)             ─ reuses Lab 1's BoundedBlockingQueue
  │           │
  │           ├─→ Lab 4 (Coroutine Scheduler) ─ shutdown semantics follow Lab 3
  │           │     │
  │           │     └─→ Lab 5 (Channel/Actor) ─ can reuse Lab 1's queue
  │           │
  │           └─→ Capstone (Mini Runtime)   ─ composes the components of Labs 0–5

Environment Setup ​

All labs share the following environment requirements:

  • Compiler: GCC 12+ or Clang 15+ (C++20, full coroutine support)
  • CMake: 3.14+
  • Test framework: Catch2 v3 (header-only, fetched via FetchContent)
  • TSan: compile flags -fsanitize=thread -g
  • Platform: Linux or WSL2 (required for the epoll part of Lab 4)
  • Valgrind (optional; needed for helgrind in Lab 2.5)

Every lab article opens with a concrete CMakeLists.txt template that you can use directly.

pdf-latest-4-g85128cc · 85128cc · 2026-10-05