]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - doc/html/ref/posix-synchronization.html
Initial revision
[karo-tx-redboot.git] / doc / html / ref / posix-synchronization.html
1 <!-- Copyright (C) 2003 Red Hat, Inc.                                -->
2 <!-- This material may be distributed only subject to the terms      -->
3 <!-- and conditions set forth in the Open Publication License, v1.0  -->
4 <!-- or later (the latest version is presently available at          -->
5 <!-- http://www.opencontent.org/openpub/).                           -->
6 <!-- Distribution of the work or derivative of the work in any       -->
7 <!-- standard (paper) book form is prohibited unless prior           -->
8 <!-- permission is obtained from the copyright holder.               -->
9 <HTML
10 ><HEAD
11 ><TITLE
12 >Synchronization [POSIX Section 11]</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
14 <META
15 NAME="GENERATOR"
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
17 "><LINK
18 REL="HOME"
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
21 REL="UP"
22 TITLE="POSIX Standard Support"
23 HREF="posix-standard-support.html"><LINK
24 REL="PREVIOUS"
25 TITLE="Data Interchange Format [POSIX Section 10]"
26 HREF="posix-data-interchange-format.html"><LINK
27 REL="NEXT"
28 TITLE="Memory Management [POSIX Section 12]"
29 HREF="posix-memory-management.html"></HEAD
30 ><BODY
31 CLASS="SECT1"
32 BGCOLOR="#FFFFFF"
33 TEXT="#000000"
34 LINK="#0000FF"
35 VLINK="#840084"
36 ALINK="#0000FF"
37 ><DIV
38 CLASS="NAVHEADER"
39 ><TABLE
40 SUMMARY="Header navigation table"
41 WIDTH="100%"
42 BORDER="0"
43 CELLPADDING="0"
44 CELLSPACING="0"
45 ><TR
46 ><TH
47 COLSPAN="3"
48 ALIGN="center"
49 >eCos Reference Manual</TH
50 ></TR
51 ><TR
52 ><TD
53 WIDTH="10%"
54 ALIGN="left"
55 VALIGN="bottom"
56 ><A
57 HREF="posix-data-interchange-format.html"
58 ACCESSKEY="P"
59 >Prev</A
60 ></TD
61 ><TD
62 WIDTH="80%"
63 ALIGN="center"
64 VALIGN="bottom"
65 >Chapter 31. POSIX Standard Support</TD
66 ><TD
67 WIDTH="10%"
68 ALIGN="right"
69 VALIGN="bottom"
70 ><A
71 HREF="posix-memory-management.html"
72 ACCESSKEY="N"
73 >Next</A
74 ></TD
75 ></TR
76 ></TABLE
77 ><HR
78 ALIGN="LEFT"
79 WIDTH="100%"></DIV
80 ><DIV
81 CLASS="SECT1"
82 ><H1
83 CLASS="SECT1"
84 ><A
85 NAME="POSIX-SYNCHRONIZATION">Synchronization &#0091;POSIX Section 11&#0093;</H1
86 ><DIV
87 CLASS="SECT2"
88 ><H2
89 CLASS="SECT2"
90 ><A
91 NAME="AEN13150">Functions Implemented</H2
92 ><TABLE
93 BORDER="5"
94 BGCOLOR="#E0E0F0"
95 WIDTH="70%"
96 ><TR
97 ><TD
98 ><PRE
99 CLASS="SCREEN"
100 >int sem&#0095;init(sem&#0095;t &#0042;sem, int pshared, unsigned int value); 
101 int sem&#0095;destroy(sem&#0095;t &#0042;sem); 
102 int sem&#0095;wait(sem&#0095;t &#0042;sem); 
103 int sem&#0095;trywait(sem&#0095;t &#0042;sem); 
104 int sem&#0095;post(sem&#0095;t &#0042;sem);
105 int sem&#0095;getvalue(sem&#0095;t &#0042;sem, int &#0042;sval); 
106 int pthread&#0095;mutexattr&#0095;init( pthread&#0095;mutexattr&#0095;t &#0042;attr); 
107 int pthread&#0095;mutexattr&#0095;destroy( pthread&#0095;mutexattr&#0095;t &#0042;attr); 
108 int pthread&#0095;mutex&#0095;init(pthread&#0095;mutex&#0095;t &#0042;mutex,
109                        const pthread&#0095;mutexattr&#0095;t &#0042;mutex&#0095;attr); 
110 int pthread&#0095;mutex&#0095;destroy(pthread&#0095;mutex&#0095;t &#0042;mutex); 
111 int pthread&#0095;mutex&#0095;lock(pthread&#0095;mutex&#0095;t &#0042;mutex); 
112 int pthread&#0095;mutex&#0095;trylock(pthread&#0095;mutex&#0095;t &#0042;mutex); 
113 int pthread&#0095;mutex&#0095;unlock(pthread&#0095;mutex&#0095;t &#0042;mutex); 
114 int pthread&#0095;condattr&#0095;init(pthread&#0095;condattr&#0095;t &#0042;attr); 
115 int pthread&#0095;condattr&#0095;destroy(pthread&#0095;condattr&#0095;t &#0042;attr); 
116 int pthread&#0095;cond&#0095;init(pthread&#0095;cond&#0095;t &#0042;cond, 
117                        const pthread&#0095;condattr&#0095;t &#0042;attr); 
118 int pthread&#0095;cond&#0095;destroy(pthread&#0095;cond&#0095;t &#0042;cond); 
119 int pthread&#0095;cond&#0095;signal(pthread&#0095;cond&#0095;t &#0042;cond); 
120 int pthread&#0095;cond&#0095;broadcast(pthread&#0095;cond&#0095;t &#0042;cond); 
121 int pthread&#0095;cond&#0095;wait(pthread&#0095;cond&#0095;t &#0042;cond, 
122                        pthread&#0095;mutex&#0095;t &#0042;mutex);
123 int pthread&#0095;cond&#0095;timedwait(pthread&#0095;cond&#0095;t &#0042;cond,
124                            pthread&#0095;mutex&#0095;t &#0042;mutex,
125                            const struct timespec &#0042;abstime);</PRE
126 ></TD
127 ></TR
128 ></TABLE
129 ></DIV
130 ><DIV
131 CLASS="SECT2"
132 ><H2
133 CLASS="SECT2"
134 ><A
135 NAME="AEN13153">Functions Omitted</H2
136 ><TABLE
137 BORDER="5"
138 BGCOLOR="#E0E0F0"
139 WIDTH="70%"
140 ><TR
141 ><TD
142 ><PRE
143 CLASS="SCREEN"
144 >sem&#0095;t &#0042;sem&#0095;open(const char &#0042;name, int oflag, ...);             &#0047;&#0047; TBA 
145 int sem&#0095;close(sem&#0095;t &#0042;sem);                                    &#0047;&#0047; TBA 
146 int sem&#0095;unlink(const char &#0042;name);                           &#0047;&#0047; TBA 
147 int pthread&#0095;mutexattr&#0095;getpshared( const pthread&#0095;mutexattr&#0095;t &#0042;attr,
148                                   int &#0042;pshared );
149 int pthread&#0095;mutexattr&#0095;setpshared( const pthread&#0095;mutexattr&#0095;t &#0042;attr,
150                                   int pshared );
151 int  pthread&#0095;condattr&#0095;getpshared( const pthread&#0095;condattr&#0095;t &#0042;attr, 
152                                   int &#0042;pshared);
153 int  pthread&#0095;condattr&#0095;setpshared( const pthread&#0095;condattr&#0095;t &#0042;attr,
154                                   int pshared);</PRE
155 ></TD
156 ></TR
157 ></TABLE
158 ></DIV
159 ><DIV
160 CLASS="SECT2"
161 ><H2
162 CLASS="SECT2"
163 ><A
164 NAME="AEN13156">Notes</H2
165 ><P
166 ></P
167 ><UL
168 ><LI
169 ><P
170 >           The presence of semaphores is controlled by the
171             CYGPKG&#0095;POSIX&#0095;SEMAPHORES option. This in turn
172             causes the &#0095;POSIX&#0095;SEMAPHORES feature test
173             macro to be defined and the semaphore API to be made
174             available.
175             </P
176 ></LI
177 ><LI
178 ><P
179 >           The <SPAN
180 CLASS="strong"
181 ><B
182 CLASS="EMPHASIS"
183 >pshared</B
184 ></SPAN
185 > argument to
186             <SPAN
187 CLASS="emphasis"
188 ><I
189 CLASS="EMPHASIS"
190 >sem&#0095;init()</I
191 ></SPAN
192 > is not implemented,
193             its value is ignored.
194             </P
195 ></LI
196 ><LI
197 ><P
198 >           Functions <SPAN
199 CLASS="emphasis"
200 ><I
201 CLASS="EMPHASIS"
202 >sem&#0095;open()</I
203 ></SPAN
204 >, 
205             <SPAN
206 CLASS="emphasis"
207 ><I
208 CLASS="EMPHASIS"
209 >sem&#0095;close()</I
210 ></SPAN
211 > and
212             <SPAN
213 CLASS="emphasis"
214 ><I
215 CLASS="EMPHASIS"
216 >sem&#0095;unlink()</I
217 ></SPAN
218 > are present but
219             always return an error (ENOSYS).
220             </P
221 ></LI
222 ><LI
223 ><P
224 >           The exact priority inversion protocols supported may be
225             controlled with the
226             &#0095;POSIX&#0095;THREAD&#0095;PRIO&#0095;INHERIT and
227             &#0095;POSIX&#0095;THREAD&#0095;PRIO&#0095;PROTECT
228             configuration options.
229             </P
230 ></LI
231 ><LI
232 ><P
233 >           &#0123;&#0095;POSIX&#0095;THREAD&#0095;PROCESS&#0095;SHARED&#0125; is
234             not defined, so the 
235             <SPAN
236 CLASS="strong"
237 ><B
238 CLASS="EMPHASIS"
239 >process-shared</B
240 ></SPAN
241 > mutex
242             and condition variable attributes are not supported, and
243             neither are the functions
244             <SPAN
245 CLASS="emphasis"
246 ><I
247 CLASS="EMPHASIS"
248 >pthread&#0095;mutexattr&#0095;getpshared()</I
249 ></SPAN
250 >,
251             <SPAN
252 CLASS="emphasis"
253 ><I
254 CLASS="EMPHASIS"
255 >pthread&#0095;mutexattr&#0095;setpshared()</I
256 ></SPAN
257 >, 
258             <SPAN
259 CLASS="emphasis"
260 ><I
261 CLASS="EMPHASIS"
262 >pthread&#0095;condattr&#0095;getpshared()</I
263 ></SPAN
264 > and 
265             <SPAN
266 CLASS="emphasis"
267 ><I
268 CLASS="EMPHASIS"
269 >pthread&#0095;condattr&#0095;setpshared()</I
270 ></SPAN
271 >. 
272             </P
273 ></LI
274 ><LI
275 ><P
276 >           Condition variables do not become bound to a particular
277             mutex when
278             <SPAN
279 CLASS="emphasis"
280 ><I
281 CLASS="EMPHASIS"
282 >pthread&#0095;cond&#0095;wait()</I
283 ></SPAN
284 > is
285             called. Hence different threads may wait on a condition
286             variable with different mutexes. This is at variance with
287             the standard, which requires a condition variable to
288             become (dynamically) bound by the first waiter, and
289             unbound when the last finishes. However, this difference
290             is largely benign, and the cost of policing this feature
291             is non-trivial.
292           </P
293 ></LI
294 ></UL
295 ></DIV
296 ></DIV
297 ><DIV
298 CLASS="NAVFOOTER"
299 ><HR
300 ALIGN="LEFT"
301 WIDTH="100%"><TABLE
302 SUMMARY="Footer navigation table"
303 WIDTH="100%"
304 BORDER="0"
305 CELLPADDING="0"
306 CELLSPACING="0"
307 ><TR
308 ><TD
309 WIDTH="33%"
310 ALIGN="left"
311 VALIGN="top"
312 ><A
313 HREF="posix-data-interchange-format.html"
314 ACCESSKEY="P"
315 >Prev</A
316 ></TD
317 ><TD
318 WIDTH="34%"
319 ALIGN="center"
320 VALIGN="top"
321 ><A
322 HREF="ecos-ref.html"
323 ACCESSKEY="H"
324 >Home</A
325 ></TD
326 ><TD
327 WIDTH="33%"
328 ALIGN="right"
329 VALIGN="top"
330 ><A
331 HREF="posix-memory-management.html"
332 ACCESSKEY="N"
333 >Next</A
334 ></TD
335 ></TR
336 ><TR
337 ><TD
338 WIDTH="33%"
339 ALIGN="left"
340 VALIGN="top"
341 >Data Interchange Format &#0091;POSIX Section 10&#0093;</TD
342 ><TD
343 WIDTH="34%"
344 ALIGN="center"
345 VALIGN="top"
346 ><A
347 HREF="posix-standard-support.html"
348 ACCESSKEY="U"
349 >Up</A
350 ></TD
351 ><TD
352 WIDTH="33%"
353 ALIGN="right"
354 VALIGN="top"
355 >Memory Management &#0091;POSIX Section 12&#0093;</TD
356 ></TR
357 ></TABLE
358 ></DIV
359 ></BODY
360 ></HTML
361 >