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

Sign in to watch this lesson
The C++ Memory Model and Atomics · 4:20
The standard atomics and the operation lock-free code is built from. We cover load, store, exchange and the fetch operations (which return the old value), why atomics can't be copied, and which sizes are lock-free on an Apple M3 (up to 16 bytes; a 24-byte struct falls back to a lock in the runtime). Compare-exchange is pictured as a slot machine that reloads expected on failure, used in a fetch_multiply loop, and we measure spurious failure: on plain ARMv8 code, compare_exchange_weak failed over three million times in ten million when a neighbour wrote the same cache line, while strong and the M3's single casal instruction never failed.