liveBook · Manning

Thread-aware memory model

As explained in C++ Concurrency in Action, Second Edition

A programming-language memory model that defines how operations on memory behave and become visible across threads.

A thread-aware memory model defines how memory operations behave across threads and provides the guarantees that make C++ concurrency facilities reliable. Its precise rules matter most when synchronizing with low-level atomic operations; mutex-protected data and standard signaling facilities often let programmers avoid reasoning about those details. section 5.0 section 1.3.2

The model has two aspects:

  • Structural aspects concern how objects and memory locations are laid out. section 5.1
  • Concurrency aspects define how operations can synchronize between threads, including through atomic types and operations. section 5.0

C++98 did not formally define a memory model, so multithreaded programs relied on compiler-specific extensions. C++11 established a thread-aware model alongside standard-library support for managing threads, protecting shared data, and synchronizing operations. section 1.3.1 section 1.3.2

How C++ Concurrency in Action, Second Edition covers it

How deep it goes
Introduces structural and concurrency aspects, including objects and memory locations, then directs detailed study toward atomic operations and synchronization.
Examples
Uses mutex-protected data and standard signaling facilities as familiar cases, and points to lock-free data structures as a low-level use.
What you can do after
Understand why concurrency facilities require defined memory behavior and when precise guarantees matter for low-level synchronization.
How it connects
Connects objects and memory locations with atomic operations, mutexes, condition variables, futures, latches, barriers, and lock-free data structures.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of C++ Concurrency in Action, Second Edition. The section links point to the parts of the book it draws on.