Threads, Mutexes, and Atomics: Start with What Can Go Wrong
Comments
Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules
Ranked by a public rubric, not by votes: what a comment adds counts, not who wrote it. How comments are ranked · Comment rules
Summary
Ted Koomen's Critical Section post opens a series on thread synchronization in C++20, working from what the language guarantees to what the OS and CPU do. It shows that an unsynchronized counter is a data race and therefore undefined behavior, then covers mutexes, relaxed atomics, acquire/release publication, compare-and-swap loops and the ABA problem, with a versioned-state fix. Its claims about the uncontended Linux mutex path and x86 instruction choices cite no sources. The follow-up part promises measurements; this one has none.