atomic_ops - atomic operations
#include <atomic.h>
This collection of functions provides atomic memory operations. There are 8 different classes of atomic operations:
atomic_add(3C)
atomic_and(3C)
atomic_bits(3C)
atomic_cas(3C)
atomic_dec(3C)
atomic_inc(3C)
atomic_or(3C)
atomic_swap(3C)
See attributes(5) for descriptions of the following attributes:
|
atomic_add(3C), atomic_and(3C), atomic_bits(3C), atomic_cas(3C), atomic_dec(3C), atomic_inc(3C), atomic_or(3C), atomic_swap(3C), membar_ops(3C), attributes(5)
Atomic instructions ensure global visibility of atomically-modified variables on completion. In a relaxed store order system, this does not guarantee that the visibility of other variables will be synchronized with the completion of the atomic instruction. If such synchronization is required, memory barrier instructions must be used. See membar_ops(3C).
Atomic instructions can be expensive. since they require synchronization to occur at a hardware level. This means they should be used with care to ensure that forcing hardware level synchronization occurs a minimum number of times. For example, if you have several variables that need to be incremented as a group, and each needs to be done atomically, then do so with a mutex lock protecting all of them being incremented rather than using the atomic_inc(3C) operation on each of them.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |