1atomic_ops(3C)           Standard C Library Functions           atomic_ops(3C)
2
3
4

NAME

6       atomic_ops - atomic operations
7

SYNOPSIS

9       #include <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(3C)     These functions provide  an  atomic  addition  of  a
17                          signed value to a variable.
18
19
20       atomic_and(3C)     These functions provide an atomic logical 'and' of a
21                          value to a variable.
22
23
24       atomic_bits(3C)    These  functions  provide  atomic  bit  setting  and
25                          clearing within a variable.
26
27
28       atomic_cas(3C)     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(3C)     These functions provide an  atomic  decrement  on  a
35                          variable.
36
37
38       atomic_inc(3C)     These  functions  provide  an  atomic increment on a
39                          variable.
40
41
42       atomic_or(3C)      These functions provide an atomic logical 'or' of  a
43                          value to a variable.
44
45
46       atomic_swap(3C)    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          │Stable                       │
61       ├─────────────────────────────┼─────────────────────────────┤
62       │MT-Level                     │MT-Safe                      │
63       └─────────────────────────────┴─────────────────────────────┘
64

SEE ALSO

66       atomic_add(3C),    atomic_and(3C),   atomic_bits(3C),   atomic_cas(3C),
67       atomic_dec(3C), atomic_inc(3C),  atomic_or(3C),  atomic_swap(3C),  mem‐
68       bar_ops(3C), attributes(5)
69

NOTES

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