Search⌘ K

Weak Memory Model

Understand the weak memory model in C++ atomic operations and how it influences thread behavior and synchronization. Learn about relaxed and acquire-release semantics, their effects on program ordering, and the guarantees provided by sequential consistency to write safer concurrent code.

Let’s refer to the contract between the programmer and the system.

The programmer uses atomics in this particular example; He obeys his part of the contract. The system guarantees well-defined program behavior without data races. In addition to that, the system can execute the four operations in each combination. If the programmer uses the relaxed semantic, the pillars of the contract dramatically change. On one hand, it is a lot more ...