Skip to content

Atomic Operations

Atomic operations are basically "all or nothing" operations.

All atomic operations are groups of instructions (not just one instruction).
They either all need to be completed in their entirety, or none of them are completed.

Definition

In computing, atomic operations are operations that are performed as a single, indivisible unit of execution.

This means that an atomic operation either completes in its entirety
without any interference from concurrent operations, or it does not occur at all.

Atomicity guarantees that no other processes or threads can observe the
operation in an incomplete state.

In the context of multi-threaded or multi-process environments, ensuring
atomicity is crucial for maintaining data integrity and preventing race conditions, where the outcome of operations depends on the sequence
or timing of other uncontrollable events.


Atomic operations are commonly used in low-level programming, such
as operating system kernel development, and in the development of
concurrent data structures.

They are supported directly by hardware (CPU) instructions, which can
execute complex operations (like incrementing a counter, swapping
values, or conditional updates) without interruption.