The atomic_flag_test_and_set
function is defined in the <stdatomic.h>
header file in C. It takes in a single parameter: a volatile atomic_flag
object. The function returns the value of the atomic_flag pointed to by the obj
and then sets the current value to true
.
atomic_flag
is anatomic boolean
type variable that is guaranteed to be lock-free. It is used to provide synchronization within threads in programs.
The illustration below shows how atomic_flag_test_and_set
works:
The atomic_flag_test_and_set
function is defined as follows:
bool atomic_flag_test_and_set( volatile atomic_flag* obj );
Theatomic_flag_test_and_set
function takes in a single value of type volatile atomic flag*
.
The atomic_flag_test_and_set
function returns a boolean
value which indicates the state of the flag. The value can be either true
or false
.
The
atomic_flag_test_and_set
is outdated and has been replaced by theatomic_flag_test_and_set_explicit
function. Therefore, relevant code foratomic_flag_test_and_set
function does not exist.
Free Resources