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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
'\" te
.\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright 1989 AT&T
.\" 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 SEMGET 2 "Aug 14, 2006"
.SH NAME
semget \- get set of semaphores
.SH SYNOPSIS
.LP
.nf
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
\fBint\fR \fBsemget\fR(\fBkey_t\fR \fIkey\fR, \fBint\fR \fInsems\fR, \fBint\fR \fIsemflg\fR);
.fi
.SH DESCRIPTION
.sp
.LP
The \fBsemget()\fR function returns the semaphore identifier associated with
\fIkey\fR.
.sp
.LP
A semaphore identifier and associated data structure and set containing
\fInsems\fR semaphores (see \fBIntro\fR(2)) are created for \fIkey\fR if one of
the following is true:
.RS +4
.TP
.ie t \(bu
.el o
\fIkey\fR is equal to \fBIPC_PRIVATE\fR.
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fIkey\fR does not already have a semaphore identifier associated with it, and
(\fIsemflg\fR\fB&IPC_CREAT\fR) is true.
.RE
.sp
.LP
On creation, the data structure associated with the new semaphore identifier is
initialized as follows:
.RS +4
.TP
.ie t \(bu
.el o
\fBsem_perm.cuid\fR, \fBsem_perm.uid\fR, \fBsem_perm.cgid\fR, and
\fBsem_perm.gid\fR are set equal to the effective user \fBID\fR and effective
group \fBID,\fR respectively, of the calling process.
.RE
.RS +4
.TP
.ie t \(bu
.el o
The access permission bits of \fBsem_perm.mode\fR are set equal to the access
permission bits of \fIsemflg\fR.
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBsem_nsems\fR is set equal to the value of \fInsems\fR.
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fBsem_otime\fR is set equal to 0 and \fBsem_ctime\fR is set equal to the
current time.
.RE
.SH RETURN VALUES
.sp
.LP
Upon successful completion, a non-negative integer representing a semaphore
identifier is returned. Otherwise, \fB\(mi1\fR is returned and \fBerrno\fR is
set to indicate the error.
.SH ERRORS
.sp
.LP
The \fBsemget()\fR function will fail if:
.sp
.ne 2
.na
\fB\fBEACCES\fR\fR
.ad
.RS 10n
A semaphore identifier exists for \fIkey\fR, but operation permission (see
\fBIntro\fR(2)) as specified by the low-order 9 bits of \fIsemflg\fR would not
be granted.
.RE
.sp
.ne 2
.na
\fB\fBEEXIST\fR\fR
.ad
.RS 10n
A semaphore identifier exists for \fIkey\fR but both
(\fIsemflg\fR\fB&IPC_CREAT\fR) and (\fIsemflg\fR\fB&IPC_EXCL\fR) are both true.
.RE
.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
The \fInsems\fR argument is either less than or equal to 0 or greater than the
system-imposed limit. See NOTES.
.sp
A semaphore identifier exists for \fIkey\fR, but the number of semaphores in
the set associated with it is less than \fInsems\fR and \fInsems\fR is not
equal to 0.
.RE
.sp
.ne 2
.na
\fB\fBENOENT\fR\fR
.ad
.RS 10n
A semaphore identifier does not exist for \fIkey\fR and
(\fIsemflg\fR\fB&IPC_CREAT\fR) is false.
.RE
.sp
.ne 2
.na
\fB\fBENOSPC\fR\fR
.ad
.RS 10n
A semaphore identifier is to be created but the system-imposed limit on the
maximum number of allowed semaphores or semaphore identifiers system-wide would
be exceeded. See NOTES.
.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 Standard
.TE
.SH SEE ALSO
.sp
.LP
\fBipcrm\fR(1), \fBipcs\fR(1), \fBrctladm\fR(1M), \fBIntro\fR(2),
\fBsemctl\fR(2), \fBsemop\fR(2), \fBsetrctl\fR(2), \fBftok\fR(3C),
\fBattributes\fR(5), \fBstandards\fR(5)
.SH NOTES
.sp
.LP
The system-imposed limit on the value of the \fInsems\fR argument is the
maintained on a per-process basis using the \fBprocess.max-sem-nsems\fR
resource control.
.sp
.LP
The system-imposed limit on the number of semaphore identifiers is maintained
on a per-project basis using the \fBproject.max-sem-ids\fR resource control.
The \fBzone.max-sem-ids\fR resource control limis the total number of
semaphore identifiers that can be allocated by a zone.
.sp
.LP
See \fBrctladm\fR(1M) and \fBsetrctl\fR(2) for information about using resource
controls.
|