1atomic_ops(9F)           Kernel Functions for Drivers           atomic_ops(9F)
2
3
4

NAME

6       atomic_ops - atomic operations
7

SYNOPSIS

9       #include <sys/atomic.h>
10
11

DESCRIPTION

13       This  collection  of functions provides atomic memory operations. There
14       are 8 different classes of atomic operations:
15
16       atomic_add(9F)     These functions provide  an  atomic  addition  of  a
17                          signed value to a variable.
18
19
20       atomic_and(9F)     These functions provide an atomic logical 'and' of a
21                          value to a variable.
22
23
24       atomic_bits(9F)    These  functions  provide  atomic  bit  setting  and
25                          clearing within a variable.
26
27
28       atomic_cas(9F)     These  functions  provide  an atomic comparison of a
29                          value with a variable. If the comparison  is  equal,
30                          then swap in a new value for the variable, returning
31                          the old value of the variable in either case.
32
33
34       atomic_dec(9F)     These functions provide an  atomic  decrement  on  a
35                          variable.
36
37
38       atomic_inc(9F)     These  functions  provide  an  atomic increment on a
39                          variable.
40
41
42       atomic_or(9F)      These functions provide an atomic logical 'or' of  a
43                          value to a variable.
44
45
46       atomic_swap(9F)    These  functions  provide  an atomic swap of a value
47                          with a variable, returning  the  old  value  of  the
48                          variable.
49
50

ATTRIBUTES

52       See attributes(5) for descriptions of the following attributes:
53
54
55
56
57       ┌─────────────────────────────┬─────────────────────────────┐
58       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
59       ├─────────────────────────────┼─────────────────────────────┤
60       │Interface Stability          │Committed                    │
61       └─────────────────────────────┴─────────────────────────────┘
62

SEE ALSO

64       atomic_add(9F),    atomic_and(9F),   atomic_bits(9F),   atomic_cas(9F),
65       atomic_dec(9F), atomic_inc(9F),  atomic_or(9F),  atomic_swap(9F),  mem‐
66       bar_ops(9F), attributes(5)
67

NOTES

69       Atomic  instructions  ensure  global  visibility of atomically-modified
70       variables on completion.  In a relaxed store order  system,  this  does
71       not  guarantee  that the visibility of other variables will be synchro‐
72       nized with the completion of the atomic instruction. If  such  synchro‐
73       nization  is  required,  memory  barrier instructions must be used. See
74       membar_ops(9F).
75
76
77       Atomic instructions can be expensive. since they  require  synchroniza‐
78       tion  to occur at a hardware level. This means they should be used with
79       care to ensure that forcing hardware  level  synchronization  occurs  a
80       minimum  number  of  times.  For example, if you have several variables
81       that need to be incremented as a group, and each needs to be done atom‐
82       ically,  then  do  so  with  a  mutex lock protecting all of them being
83       incremented rather than using the atomic_inc(9F) operation on  each  of
84       them.
85
86
87
88SunOS 5.11                        28 Mar 2005                   atomic_ops(9F)
Impressum