Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 26s8 days 9 hours 54 minutes 26 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 26s8 days 9 hours 54 minutes 26 seconds.

Sign in to watch this lesson
The C++ Memory Model and Atomics · 4:13
volatile versus std::atomic, read straight from the arm64 instructions clang -O2 emits on a Mac. A volatile increment is a load, an add and a store, so two threads lost about half of two million increments while the atomic's single ldaddal lost none; a volatile ready flag let clang drop the value's store so the flag went out first, and ThreadSanitizer reported two data races where the atomic version reported none. We finish with what volatile is really for: memory-mapped hardware and signal handlers, where every load and store must happen.