1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
'\" te
.\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH ATOMIC_OPS 9F "Mar 28, 2005"
.SH NAME
atomic_ops \- atomic operations
.SH SYNOPSIS
.LP
.nf
#include <\fBsys/atomic.h\fR>
.fi
.SH DESCRIPTION
.sp
.LP
This collection of functions provides atomic memory operations. There are 8
different classes of atomic operations:
.sp
.ne 2
.na
\fB\fBatomic_add\fR(9F)\fR
.ad
.RS 19n
These functions provide an atomic addition of a signed value to a variable.
.RE
.sp
.ne 2
.na
\fB\fBatomic_and\fR(9F)\fR
.ad
.RS 19n
These functions provide an atomic logical 'and' of a value to a variable.
.RE
.sp
.ne 2
.na
\fB\fBatomic_bits\fR(9F)\fR
.ad
.RS 19n
These functions provide atomic bit setting and clearing within a variable.
.RE
.sp
.ne 2
.na
\fB\fBatomic_cas\fR(9F)\fR
.ad
.RS 19n
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.
.RE
.sp
.ne 2
.na
\fB\fBatomic_dec\fR(9F)\fR
.ad
.RS 19n
These functions provide an atomic decrement on a variable.
.RE
.sp
.ne 2
.na
\fB\fBatomic_inc\fR(9F)\fR
.ad
.RS 19n
These functions provide an atomic increment on a variable.
.RE
.sp
.ne 2
.na
\fB\fBatomic_or\fR(9F)\fR
.ad
.RS 19n
These functions provide an atomic logical 'or' of a value to a variable.
.RE
.sp
.ne 2
.na
\fB\fBatomic_swap\fR(9F)\fR
.ad
.RS 19n
These functions provide an atomic swap of a value with a variable, returning
the old value of the variable.
.RE
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Committed
.TE
.SH SEE ALSO
.sp
.LP
\fBatomic_add\fR(9F), \fBatomic_and\fR(9F), \fBatomic_bits\fR(9F),
\fBatomic_cas\fR(9F), \fBatomic_dec\fR(9F), \fBatomic_inc\fR(9F),
\fBatomic_or\fR(9F), \fBatomic_swap\fR(9F), \fBmembar_ops\fR(9F),
\fBattributes\fR(5)
.SH NOTES
.sp
.LP
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 \fBmembar_ops\fR(9F).
.sp
.LP
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
\fBatomic_inc\fR(9F) operation on each of them.
|