Atomics And Concurrency

Jun 16, 2025

Atomics And Concurrency. This article explains the importance of memory ordering when writing concurrent programs using atomics. Essentially, data races can occur because compilers and CPUs may reorder instructions. As a result, threads operating on shared data might observe operations in an unintended order.

Some programming languages, such as C++ and Rust, give you finer control over the memory model by exposing detailed options through their atomics APIs. In C++, for example, the memory models include:

Other languages, like Go, don’t provide this level of control. Instead, Go implements a sequentially consistent memory model under the hood.

Russ Coss does a great job explaining hardware memory models, how different programming languages exposes memory models control and Go’s memory model in the following articles:

#atomics #concurrency #memory-model