Atomic’s Memory Orders, What For?

By Frank Birbacher

Multithreading in C++ has been used successfully for many years prior to the introduction of C++11 to run programs on multi-core hardware. Then the C++11 Memory Model for multithreading was introduced with much debate as to its proper application. On the one hand some suggest not to bother with atomics and just use volatile if at all. On the other hand some might be happy to have everything guarded with mutexes. Either side may have been discouraged from looking deeper into the C++11 Memory Model, put off by its apparent complexity.

The talk will focus on different options of “memory order” when using std::atomic. It’ll explain what the memory order is and what each of the options mean. We’ll take a look at the C++ memory model, sequencing of expressions and synchronization between threads. The talk sheds light on compiler optimizations and generated assembly, examines out-of-order execution in CPUs and possible cache communication between cores. In the end it should be clear what an atomic variable does apart from storing a value.





Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.