Boost.Fiber: stackful suspension, the guard page, and the scheduler you have to choose

fiberdemo measures what a real stack costs and what it buys. boost::context::stack_traits reports a 131072-byte default fiber stack, sitting between ch53's measured 32-byte coroutine frame and ch50's measured 8388608-byte thread stack -- 8 MiB to 128 KiB to 32 bytes, with both ratios computed from measured numbers. The capability that stack buys is demonstrated rather than described: a fiber suspends from inside an ordinary non-coroutine function six frames deep and resumes there, which no stackless coroutine can do. protected_fixedsize_stack is shown costing exactly one page more than fixedsize_stack, gated against page_size(), and a 60x overflow dies of SIGSEGV on that guard page rather than corrupting the next mapping. The same 16 fibers report one distinct tid under round_robin and four under shared_work, making ch49's grid a scheduler choice. Verified against system Boost 1.90.0 on the Fedora 44 host: verify.lua PASS 32/FAIL 0, no Conan, no network.

⏱ 55 minutesChapter 54Compendium: C++ Concurrency

This chapter has moved. The C++ concurrency material has its own dedicated, runnable book: C++ Concurrency and Parallelism.

It maps to Fibers and Stackful Coroutines there.

The full, runnable C++ treatment of concurrency and parallelism — threads and jthread, mutexes and the memory model, atomics and lock-free structures, futures and coroutines, fibers, Asio, NUMA and mechanical sympathy, and the low-latency patterns — now lives in that book, each chapter with a Docker or KVM-lab demo and a Lua verify.lua behind it. This book keeps its Linux systems-programming material; the C++ concurrency compendium was extracted so it could grow on its own.