2 .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" 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.
5 .\" 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.
6 .\" 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]
7 .TH SEMGET 2 "Aug 14, 2006"
9 semget \- get set of semaphores
13 #include <sys/types.h>
17 \fBint\fR \fBsemget\fR(\fBkey_t\fR \fIkey\fR, \fBint\fR \fInsems\fR, \fBint\fR \fIsemflg\fR);
23 The \fBsemget()\fR function returns the semaphore identifier associated with
27 A semaphore identifier and associated data structure and set containing
28 \fInsems\fR semaphores (see \fBIntro\fR(2)) are created for \fIkey\fR if one of
29 the following is true:
34 \fIkey\fR is equal to \fBIPC_PRIVATE\fR.
40 \fIkey\fR does not already have a semaphore identifier associated with it, and
41 (\fIsemflg\fR\fB&IPC_CREAT\fR) is true.
45 On creation, the data structure associated with the new semaphore identifier is
46 initialized as follows:
51 \fBsem_perm.cuid\fR, \fBsem_perm.uid\fR, \fBsem_perm.cgid\fR, and
52 \fBsem_perm.gid\fR are set equal to the effective user \fBID\fR and effective
53 group \fBID,\fR respectively, of the calling process.
59 The access permission bits of \fBsem_perm.mode\fR are set equal to the access
60 permission bits of \fIsemflg\fR.
66 \fBsem_nsems\fR is set equal to the value of \fInsems\fR.
72 \fBsem_otime\fR is set equal to 0 and \fBsem_ctime\fR is set equal to the
78 Upon successful completion, a non-negative integer representing a semaphore
79 identifier is returned. Otherwise, \fB\(mi1\fR is returned and \fBerrno\fR is
80 set to indicate the error.
84 The \fBsemget()\fR function will fail if:
91 A semaphore identifier exists for \fIkey\fR, but operation permission (see
92 \fBIntro\fR(2)) as specified by the low-order 9 bits of \fIsemflg\fR would not
102 A semaphore identifier exists for \fIkey\fR but both
103 (\fIsemflg\fR\fB&IPC_CREAT\fR) and (\fIsemflg\fR\fB&IPC_EXCL\fR) are both true.
112 The \fInsems\fR argument is either less than or equal to 0 or greater than the
113 system-imposed limit. See NOTES.
115 A semaphore identifier exists for \fIkey\fR, but the number of semaphores in
116 the set associated with it is less than \fInsems\fR and \fInsems\fR is not
126 A semaphore identifier does not exist for \fIkey\fR and
127 (\fIsemflg\fR\fB&IPC_CREAT\fR) is false.
136 A semaphore identifier is to be created but the system-imposed limit on the
137 maximum number of allowed semaphores or semaphore identifiers system-wide would
138 be exceeded. See NOTES.
144 See \fBattributes\fR(5) for descriptions of the following attributes:
152 ATTRIBUTE TYPE ATTRIBUTE VALUE
154 Interface Stability Standard
160 \fBipcrm\fR(1), \fBipcs\fR(1), \fBrctladm\fR(1M), \fBIntro\fR(2),
161 \fBsemctl\fR(2), \fBsemop\fR(2), \fBsetrctl\fR(2), \fBftok\fR(3C),
162 \fBattributes\fR(5), \fBstandards\fR(5)
166 The system-imposed limit on the value of the \fInsems\fR argument is the
167 maintained on a per-process basis using the \fBprocess.max-sem-nsems\fR
171 The system-imposed limit on the number of semaphore identifiers is maintained
172 on a per-project basis using the \fBproject.max-sem-ids\fR resource control.
173 The \fBzone.max-sem-ids\fR resource control limis the total number of
174 semaphore identifiers that can be allocated by a zone.
177 See \fBrctladm\fR(1M) and \fBsetrctl\fR(2) for information about using resource