Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

atomic_ops(9f) [opensolaris man page]

atomic_ops(9F)						   Kernel Functions for Drivers 					    atomic_ops(9F)

NAME
atomic_ops - atomic operations SYNOPSIS
#include <sys/atomic.h> DESCRIPTION
This collection of functions provides atomic memory operations. There are 8 different classes of atomic operations: atomic_add(9F) These functions provide an atomic addition of a signed value to a variable. atomic_and(9F) These functions provide an atomic logical 'and' of a value to a variable. atomic_bits(9F) These functions provide atomic bit setting and clearing within a variable. atomic_cas(9F) These functions provide an atomic comparison of a value with a variable. If the comparison is equal, then swap in a new value for the variable, returning the old value of the variable in either case. atomic_dec(9F) These functions provide an atomic decrement on a variable. atomic_inc(9F) These functions provide an atomic increment on a variable. atomic_or(9F) These functions provide an atomic logical 'or' of a value to a variable. atomic_swap(9F) These functions provide an atomic swap of a value with a variable, returning the old value of the variable. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ SEE ALSO
atomic_add(9F), atomic_and(9F), atomic_bits(9F), atomic_cas(9F), atomic_dec(9F), atomic_inc(9F), atomic_or(9F), atomic_swap(9F), mem- bar_ops(9F), attributes(5) NOTES
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 synchro- nization is required, memory barrier instructions must be used. See membar_ops(9F). 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(9F) operation on each of them. SunOS 5.11 28 Mar 2005 atomic_ops(9F)

Check Out this Related Man Page

membar_ops(9F)															    membar_ops(9F)

NAME
membar_ops, membar_enter, membar_exit, membar_producer, membar_consumer - memory access synchronization barrier operations SYNOPSIS
#include <sys/atomic.h> void membar_enter(void); void membar_exit(void); void membar_producer(void); void membar_consumer(void); The membar_enter() function is a generic memory barrier used during lock entry. It is placed after the memory operation that acquires the lock to guarantee that the lock protects its data. No stores from after the memory barrier will reach visibility and no loads from after the barrier will be resolved before the lock acquisition reaches global visibility. The membar_exit() function is a generic memory barrier used during lock exit. It is placed before the memory operation that releases the lock to guarantee that the lock protects its data. All loads and stores issued before the barrier will be resolved before the sub- sequent lock update reaches visibility. The membar_enter() and membar_exit() functions are used together to allow regions of code to be in relaxed store order and then ensure that the load or store order is maintained at a higher level. They are useful in the implementation of mutex exclusion locks. The membar_producer() function arranges for all stores issued before this point in the code to reach global visibility before any stores that follow. This is useful in producer modules that update a data item, then set a flag that it is available. The memory barrier guaran- tees that the available flag is not visible earlier than the updated data, thereby imposing store ordering. The membar_consumer() function arranges for all loads issued before this point in the code to be completed before any subsequent loads. This is useful in consumer modules that check if data is available and read the data. The memory barrier guarantees that the data is not sampled until after the available flag has been seen, thereby imposing load ordering. No values are returned. No errors are defined. These functions can be called from user or interrupt context. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ atomic_add(9F), atomic_and(9F), atomic_bits(9F), atomic_cas(9F), atomic_dec(9F), atomic_inc(9F), atomic_ops(9F), atomic_or(9F), atomic_swap(9F), attributes(5), atomic_ops(3C) Atomic instructions (see atomic_ops(9F)) 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. 28 Mar 2005 membar_ops(9F)
Man Page