Updated: April 19, 2023 |
Atomically read the value of an atomic object (C11)
#include <stdatomic.h> C atomic_load( volatile A *obj ); C atomic_load_explicit( volatile A *obj, memory_order order );
The atomic_load() and atomic_load_explicit() functions are generic functions that atomically read the value of the given atomic object. The atomic_load() function orders memory access according to memory_order_seq_cst; atomic_load_explicit() orders them as specified by order.
The implementation of atomic functions may depend on the architecture. For more information, see LL/SC vs LSE atomic operations in the description in Building Embedded Systems of the cpuinfo area of the system page.
The current value of the object. The C represents the non-atomic data type that corresponds to the atomic object.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | Read the Caveats |
Signal handler | Read the Caveats |
Thread | Yes |
If this function is lock-free (see atomic_is_lock_free()), it's safe to call it from an ISR or signal handler.