Skip to content

Atomic Operations

An atomic operation appears indivisible and can establish visibility between threads.

flowchart LR J[Junior: atomic updates] --> M[Middle: memory ordering] --> S[Senior: lock-free safety] --> P[Professional: hardware and models]
flowchart LR Load --> Compute --> CAS{Compare and swap} CAS -->|failed| Load CAS -->|succeeded| Done
Level Guide You are done when
Junior Start You can choose an atomic for one value.
Middle Apply You can explain acquire and release.
Senior Operate You can handle ABA, reclamation, and contention.
Professional Design You can audit memory-model-dependent code.

Practice rule: Prefer a lock unless the atomic design has a written correctness argument and measured benefit.

Shared memory | Mutex