memory_order

Updated: May 06, 2022

Enumerated type for how regular non-atomic memory accesses are to be ordered around an atomic operation

Synopsis:

#include <stdatomic.h>

typedef enum
  {
    memory_order_relaxed = __ATOMIC_RELAXED,
    memory_order_consume = __ATOMIC_CONSUME,
    memory_order_acquire = __ATOMIC_ACQUIRE,
    memory_order_release = __ATOMIC_RELEASE,
    memory_order_acq_rel = __ATOMIC_ACQ_REL,
    memory_order_seq_cst = __ATOMIC_SEQ_CST
  } memory_order;

Description:

The memory_order enumerated type specifies how regular non-atomic memory accesses are to be ordered around an atomic operation. The members include:

memory_order_relaxed
No synchronization or ordering constraints.
memory_order_consume
No reads or writes in the current thread that depend on the value being loaded can be done before this loading.
memory_order_acquire
No reads or writes in the current thread can be done before this loading.
memory_order_release
No reads or writes in the current thread can be done before this store operation.
memory_order_acq_rel
A read-modify-write operation that is both an acquire and a release operation.
memory_order_seq_cst
A read-modify-write operation that is both an acquire and a release operation, and all operations must be done in a sequentially consistent order.

Classification:

C11