IT lexicon › Programming › Atomic operations

Atomic operations

Programming På svenska → Updated: 2026-05-24

Operation completed as a unit — either entirely or not at all. Crucial in concurrent systems to avoid data races without locking.

CPU support: LOCK XADD (x86), LDXR/STXR (ARM), cmpxchg (compare-and-swap). C++ std::atomic, Java AtomicInteger, Rust AtomicUsize, Go sync/atomic. Memory ordering: sequentially consistent (default, most expensive), acquire/release, relaxed. Lock-free data structures (queue, stack) are built on CAS loops. Wait-free is stricter (each thread makes progress in bounded steps). Notoriously hard to write correctly.

← Back to the lexicon