Debian Codegraph @

upstream/mageia-cauldron/man3pm/IPC::Semaphore.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "IPC::Semaphore 3pm"
61 .TH IPC::Semaphore 3pm 2023-12-22 "perl v5.42.0" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 IPC::Semaphore \- SysV Semaphore IPC object class
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 .Vb 2
71 \& use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR IPC_CREAT);
72 \& use IPC::Semaphore;
73 \&
74 \& $sem = IPC::Semaphore\->new(IPC_PRIVATE, 10, S_IRUSR | S_IWUSR | IPC_CREAT);
75 \&
76 \& $sem\->setall( (0) x 10);
77 \&
78 \& @sem = $sem\->getall;
79 \&
80 \& $ncnt = $sem\->getncnt;
81 \&
82 \& $zcnt = $sem\->getzcnt;
83 \&
84 \& $ds = $sem\->stat;
85 \&
86 \& $sem\->remove;
87 .Ve
88 .SH DESCRIPTION
89 .IX Header "DESCRIPTION"
90 A class providing an object based interface to SysV IPC semaphores.
91 .SH METHODS
92 .IX Header "METHODS"
93 .IP "new ( KEY , NSEMS , FLAGS )" 4
94 .IX Item "new ( KEY , NSEMS , FLAGS )"
95 Create a new semaphore set associated with \f(CW\*(C`KEY\*(C'\fR. \f(CW\*(C`NSEMS\*(C'\fR is the number
96 of semaphores in the set. A new set is created if
97 .RS 4
98 .IP \(bu 4
99 \&\f(CW\*(C`KEY\*(C'\fR is equal to \f(CW\*(C`IPC_PRIVATE\*(C'\fR
100 .IP \(bu 4
101 \&\f(CW\*(C`KEY\*(C'\fR does not already have a semaphore identifier
102 associated with it, and \f(CW\*(C`\fR\f(CIFLAGS\fR\f(CW & IPC_CREAT\*(C'\fR is true.
103 .RE
104 .RS 4
105 .Sp
106 On creation of a new semaphore set \f(CW\*(C`FLAGS\*(C'\fR is used to set the
107 permissions. Be careful not to set any flags that the Sys V
108 IPC implementation does not allow: in some systems setting
109 execute bits makes the operations fail.
110 .RE
111 .IP getall 4
112 .IX Item "getall"
113 Returns the values of the semaphore set as an array.
114 .IP "getncnt ( SEM )" 4
115 .IX Item "getncnt ( SEM )"
116 Returns the number of processes waiting for the semaphore \f(CW\*(C`SEM\*(C'\fR to
117 become greater than its current value
118 .IP "getpid ( SEM )" 4
119 .IX Item "getpid ( SEM )"
120 Returns the process id of the last process that performed an operation
121 on the semaphore \f(CW\*(C`SEM\*(C'\fR.
122 .IP "getval ( SEM )" 4
123 .IX Item "getval ( SEM )"
124 Returns the current value of the semaphore \f(CW\*(C`SEM\*(C'\fR.
125 .IP "getzcnt ( SEM )" 4
126 .IX Item "getzcnt ( SEM )"
127 Returns the number of processes waiting for the semaphore \f(CW\*(C`SEM\*(C'\fR to
128 become zero.
129 .IP id 4
130 .IX Item "id"
131 Returns the system identifier for the semaphore set.
132 .IP "op ( OPLIST )" 4
133 .IX Item "op ( OPLIST )"
134 \&\f(CW\*(C`OPLIST\*(C'\fR is a list of operations to pass to \f(CW\*(C`semop\*(C'\fR. \f(CW\*(C`OPLIST\*(C'\fR is
135 a concatenation of smaller lists, each which has three values. The
136 first is the semaphore number, the second is the operation and the last
137 is a flags value. See \fBsemop\fR\|(2) for more details. For example
138 .Sp
139 .Vb 4
140 \& $sem\->op(
141 \& 0, \-1, IPC_NOWAIT,
142 \& 1, 1, IPC_NOWAIT
143 \& );
144 .Ve
145 .IP remove 4
146 .IX Item "remove"
147 Remove and destroy the semaphore set from the system.
148 .IP "set ( STAT )" 4
149 .IX Item "set ( STAT )"
150 .PD 0
151 .IP "set ( NAME => VALUE [, NAME => VALUE ...] )" 4
152 .IX Item "set ( NAME => VALUE [, NAME => VALUE ...] )"
153 .PD
154 \&\f(CW\*(C`set\*(C'\fR will set the following values of the \f(CW\*(C`stat\*(C'\fR structure associated
155 with the semaphore set.
156 .Sp
157 .Vb 3
158 \& uid
159 \& gid
160 \& mode (only the permission bits)
161 .Ve
162 .Sp
163 \&\f(CW\*(C`set\*(C'\fR accepts either a stat object, as returned by the \f(CW\*(C`stat\*(C'\fR method,
164 or a list of \fIname\fR\-\fIvalue\fR pairs.
165 .IP "setall ( VALUES )" 4
166 .IX Item "setall ( VALUES )"
167 Sets all values in the semaphore set to those given on the \f(CW\*(C`VALUES\*(C'\fR list.
168 \&\f(CW\*(C`VALUES\*(C'\fR must contain the correct number of values.
169 .IP "setval ( N , VALUE )" 4
170 .IX Item "setval ( N , VALUE )"
171 Set the \f(CW\*(C`N\*(C'\fRth value in the semaphore set to \f(CW\*(C`VALUE\*(C'\fR
172 .IP stat 4
173 .IX Item "stat"
174 Returns an object of type \f(CW\*(C`IPC::Semaphore::stat\*(C'\fR which is a sub\-class of
175 \&\f(CW\*(C`Class::Struct\*(C'\fR. It provides the following fields. For a description
176 of these fields see your system documentation.
177 .Sp
178 .Vb 8
179 \& uid
180 \& gid
181 \& cuid
182 \& cgid
183 \& mode
184 \& ctime
185 \& otime
186 \& nsems
187 .Ve
188 .SH "SEE ALSO"
189 .IX Header "SEE ALSO"
190 IPC::SysV, Class::Struct, \fBsemget\fR\|(2), \fBsemctl\fR\|(2), \fBsemop\fR\|(2)
191 .SH AUTHORS
192 .IX Header "AUTHORS"
193 Graham Barr <[email protected]>,
194 Marcus Holland\-Moritz <[email protected]>
195 .SH COPYRIGHT
196 .IX Header "COPYRIGHT"
197 Version 2.x, Copyright (C) 2007\-2013, Marcus Holland\-Moritz.
198 .PP
199 Version 1.x, Copyright (c) 1997, Graham Barr.
200 .PP
201 This program is free software; you can redistribute it and/or
202 modify it under the same terms as Perl itself.