Standard C Library Functions atomicops(3C)
NAME
atomicops - atomic operations
SYNOPSIS
#include
DESCRIPTION
This collection of functions provides atomic memory opera-
tions. There are 8 different classes of atomic operations:
atomicadd(3C) These functions provide an atomic addi-
tion of a signed value to a variable.
atomicand(3C) These functions provide an atomic logical
'and' of a value to a variable.
atomicbits(3C) These functions provide atomic bit set-
ting and clearing within a variable.
atomiccas(3C) These functions provide an atomic com-
parison 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.
atomicdec(3C) These functions provide an atomic decre-
ment on a variable.
atomicinc(3C) These functions provide an atomic incre-
ment on a variable.
atomicor(3C) These functions provide an atomic logical
'or' of a value to a variable.
atomicswap(3C) These functions provide an atomic swap of
a value with a variable, returning the
old value of the variable.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
SunOS 5.11 Last change: 12 Aug 2004 1
Standard C Library Functions atomicops(3C)
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Stable
MT-Level MT-Safe
SEE ALSO
atomicadd(3C), atomicand(3C), atomicbits(3C),
atomiccas(3C), atomicdec(3C), atomicinc(3C),
atomicor(3C), atomicswap(3C), membarops(3C), attri-
butes(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 synchronization is required,
memory barrier instructions must be used. See
membarops(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 atomicinc(3C)
operation on each of them.
SunOS 5.11 Last change: 12 Aug 2004 2
|