Atomic operations
QNX SDP8.0Programmer's GuideDeveloper
One final problem that can occur with different families of processors, and SMP configurations in general, is that of atomic access to variables.
Some convenience functions are defined that allow you to perform atomic operations (i.e., operations that are guaranteed to be indivisible or uninterruptible). Using these functions alleviates the need to disable and enable interrupts around certain small, well-defined operations with variables.
QNX OS defines the following in <atomic.h>,
which we describe in the C Library Reference:
C11 defines these in <stdatomic.h>,
which we also describe in the C Library Reference:
- atomic_compare_exchange_strong(), atomic_compare_exchange_strong_explicit(), atomic_compare_exchange_weak(), atomic_compare_exchange_weak_explicit()
- atomic_exchange(), atomic_exchange_explicit()
- atomic_fetch_add(), atomic_fetch_add_explicit()
- atomic_fetch_and(), atomic_fetch_and_explicit()
- atomic_fetch_or(), atomic_fetch_or_explicit()
- atomic_fetch_sub(), atomic_fetch_sub_explicit()
- atomic_fetch_xor(), atomic_fetch_xor_explicit()
- atomic_flag_clear(), atomic_flag_clear_explicit()
- atomic_flag_test_and_set(), atomic_flag_test_and_set_explicit()
- atomic_init()
- atomic_is_lock_free()
- atomic_load(), atomic_load_explicit()
- atomic_signal_fence()
- atomic_store(), atomic_store_explicit()
- atomic_thread_fence()
Page updated: