meta data for this page
stdatomic.h
atomic_flag
atomic_flag
is anatomic boolean
type variable that is guaranteed to be lock-free.
It is used to provide synchronization within threads in programs. Unlikeatomic_bool
,
atomic_flag
does not provide load or store operations.
#include <stdatomic.h> atomic_flag busy; if (atomic_flag_test_and_set(&busy) { return APP_ERR_BUSY; } ... atomic_flag_clear(&busy);
atomic vars
Atomic variables are not guaranteed to be lock-free. It depends on implementation, e.g: Atomic access can be provided by spin locks.