source: rtems-docs/posix_users/condition_variable.rst @ 489740f

4.115
Last change on this file since 489740f was 489740f, checked in by Chris Johns <chrisj@…>, on 05/20/16 at 02:47:09

Set SPDX License Identifier in each source file.

  • Property mode set to 100644
File size: 7.8 KB
Line 
1.. comment SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. COMMENT: COPYRIGHT (c) 1988-2002.
4.. COMMENT: On-Line Applications Research Corporation (OAR).
5.. COMMENT: All rights reserved.
6
7Condition Variable Manager
8##########################
9
10Introduction
11============
12
13The condition variable manager ...
14
15The directives provided by the condition variable manager are:
16
17- pthread_condattr_init_ - Initialize a Condition Variable Attribute Set
18
19- pthread_condattr_destroy_ - Destroy a Condition Variable Attribute Set
20
21- pthread_condattr_setpshared_ - Set Process Shared Attribute
22
23- pthread_condattr_getpshared_ - Get Process Shared Attribute
24
25- pthread_cond_init_ - Initialize a Condition Variable
26
27- pthread_cond_destroy_ - Destroy a Condition Variable
28
29- pthread_cond_signal_ - Signal a Condition Variable
30
31- pthread_cond_broadcast_ - Broadcast a Condition Variable
32
33- pthread_cond_wait_ - Wait on a Condition Variable
34
35- pthread_cond_timedwait_ - With with Timeout a Condition Variable
36
37Background
38==========
39
40There is currently no text in this section.
41
42Operations
43==========
44
45There is currently no text in this section.
46
47Directives
48==========
49
50This section details the condition variable manager's directives.  A subsection
51is dedicated to each of this manager's directives and describes the calling
52sequence, related constants, usage, and status codes.
53
54.. _pthread_condattr_init:
55
56pthread_condattr_init - Initialize a Condition Variable Attribute Set
57---------------------------------------------------------------------
58.. index:: pthread_condattr_init
59.. index:: initialize a condition variable attribute set
60
61**CALLING SEQUENCE:**
62
63.. code-block:: c
64
65    #include <pthread.h>
66    int pthread_condattr_init(
67        pthread_condattr_t *attr
68    );
69
70**STATUS CODES:**
71
72 * - ``ENOMEM``
73   - Insufficient memory is available to initialize the condition variable
74     attributes object.
75
76**DESCRIPTION:**
77
78**NOTES:**
79
80.. _pthread_condattr_destroy:
81
82pthread_condattr_destroy - Destroy a Condition Variable Attribute Set
83---------------------------------------------------------------------
84.. index:: pthread_condattr_destroy
85.. index:: destroy a condition variable attribute set
86
87**CALLING SEQUENCE:**
88
89.. code-block:: c
90
91    #include <pthread.h>
92    int pthread_condattr_destroy(
93        pthread_condattr_t *attr
94    );
95
96**STATUS CODES:**
97
98.. list-table::
99 :class: rtems-table
100
101 * - ``EINVAL``
102   - The attribute object specified is invalid.
103
104**DESCRIPTION:**
105
106**NOTES:**
107
108.. _pthread_condattr_setpshared:
109
110pthread_condattr_setpshared - Set Process Shared Attribute
111----------------------------------------------------------
112.. index:: pthread_condattr_setpshared
113.. index:: set process shared attribute
114
115**CALLING SEQUENCE:**
116
117.. code-block:: c
118
119    #include <pthread.h>
120    int pthread_condattr_setpshared(
121        pthread_condattr_t *attr,
122        int                 pshared
123    );
124
125**STATUS CODES:**
126
127.. list-table::
128 :class: rtems-table
129
130 * - ``EINVAL``
131   - Invalid argument passed.
132
133**DESCRIPTION:**
134
135**NOTES:**
136
137.. _pthread_condattr_getpshared:
138
139pthread_condattr_getpshared - Get Process Shared Attribute
140----------------------------------------------------------
141.. index:: pthread_condattr_getpshared
142.. index:: get process shared attribute
143
144**CALLING SEQUENCE:**
145
146.. code-block:: c
147
148    #include <pthread.h>
149    int pthread_condattr_getpshared(
150        const pthread_condattr_t *attr,
151        int                      *pshared
152    );
153
154**STATUS CODES:**
155
156.. list-table::
157 :class: rtems-table
158
159 * - ``EINVAL``
160   - Invalid argument passed.
161
162**DESCRIPTION:**
163
164**NOTES:**
165
166.. _pthread_cond_init:
167
168pthread_cond_init - Initialize a Condition Variable
169---------------------------------------------------
170.. index:: pthread_cond_init
171.. index:: initialize a condition variable
172
173**CALLING SEQUENCE:**
174
175.. code-block:: c
176
177    #include <pthread.h>
178    int pthread_cond_init(
179        pthread_cond_t           *cond,
180        const pthread_condattr_t *attr
181    );
182
183**STATUS CODES:**
184
185.. list-table::
186 :class: rtems-table
187
188 * - ``EAGAIN``
189   - The system lacked a resource other than memory necessary to create the
190     initialize the condition variable object.
191 * - ``ENOMEM``
192   - Insufficient memory is available to initialize the condition variable
193     object.
194 * - ``EBUSY``
195   - The specified condition variable has already been initialized.
196 * - ``EINVAL``
197   - The specified attribute value is invalid.
198
199**DESCRIPTION:**
200
201**NOTES:**
202
203.. _pthread_cond_destroy:
204
205pthread_cond_destroy - Destroy a Condition Variable
206---------------------------------------------------
207.. index:: pthread_cond_destroy
208.. index:: destroy a condition variable
209
210**CALLING SEQUENCE:**
211
212.. code-block:: c
213
214    #include <pthread.h>
215    int pthread_cond_destroy(
216        pthread_cond_t *cond
217    );
218
219**STATUS CODES:**
220
221.. list-table::
222 :class: rtems-table
223
224 * - ``EINVAL``
225   - The specified condition variable is invalid.
226 * - ``EBUSY``
227   - The specified condition variable is currently in use.
228
229**DESCRIPTION:**
230
231**NOTES:**
232
233.. _pthread_cond_signal:
234
235pthread_cond_signal - Signal a Condition Variable
236-------------------------------------------------
237.. index:: pthread_cond_signal
238.. index:: signal a condition variable
239
240**CALLING SEQUENCE:**
241
242.. code-block:: c
243
244    #include <pthread.h>
245    int pthread_cond_signal(
246        pthread_cond_t *cond
247    );
248
249**STATUS CODES:**
250
251.. list-table::
252 :class: rtems-table
253
254 * - ``EINVAL``
255   - The specified condition variable is not valid.
256
257**DESCRIPTION:**
258
259**NOTES:**
260
261This routine should not be invoked from a handler from an asynchronous signal
262handler or an interrupt service routine.
263
264.. _pthread_cond_broadcast:
265
266pthread_cond_broadcast - Broadcast a Condition Variable
267-------------------------------------------------------
268.. index:: pthread_cond_broadcast
269.. index:: broadcast a condition variable
270
271**CALLING SEQUENCE:**
272
273.. code-block:: c
274
275    #include <pthread.h>
276    int pthread_cond_broadcast(
277        pthread_cond_t *cond
278    );
279
280**STATUS CODES:**
281
282.. list-table::
283 :class: rtems-table
284
285 * - ``EINVAL``
286   - The specified condition variable is not valid.
287
288**DESCRIPTION:**
289
290**NOTES:**
291
292This routine should not be invoked from a handler from an asynchronous signal
293handler or an interrupt service routine.
294
295.. _pthread_cond_wait:
296
297pthread_cond_wait - Wait on a Condition Variable
298------------------------------------------------
299.. index:: pthread_cond_wait
300.. index:: wait on a condition variable
301
302**CALLING SEQUENCE:**
303
304.. code-block:: c
305
306    #include <pthread.h>
307    int pthread_cond_wait(
308        pthread_cond_t *cond,
309        pthread_mutex_t *mutex
310    );
311
312**STATUS CODES:**
313
314.. list-table::
315 :class: rtems-table
316
317 * - ``EINVAL``
318   - The specified condition variable or mutex is not initialized OR different
319     mutexes were specified for concurrent ``pthread_cond_wait()`` and
320     ``pthread_cond_timedwait()`` operations on the same condition variable OR
321     the mutex was not owned by the current thread at the time of the call.
322
323**DESCRIPTION:**
324
325**NOTES:**
326
327.. _pthread_cond_timedwait:
328
329pthread_cond_timedwait - Wait with Timeout a Condition Variable
330---------------------------------------------------------------
331.. index:: pthread_cond_timedwait
332.. index:: wait with timeout a condition variable
333
334**CALLING SEQUENCE:**
335
336.. code-block:: c
337
338    #include <pthread.h>
339    int pthread_cond_timedwait(
340        pthread_cond_t        *cond,
341        pthread_mutex_t       *mutex,
342        const struct timespec *abstime
343    );
344
345**STATUS CODES:**
346
347.. list-table::
348 :class: rtems-table
349
350 * - ``EINVAL``
351   - The specified condition variable or mutex is not initialized OR different
352     mutexes were specified for concurrent ``pthread_cond_wait()`` and
353     ``pthread_cond_timedwait()`` operations on the same condition variable OR
354     the mutex was not owned by the current thread at the time of the call.
355 * - ``ETIMEDOUT``
356   - The specified time has elapsed without the condition variable being
357     satisfied.
358
359**DESCRIPTION:**
360
361**NOTES:**
Note: See TracBrowser for help on using the repository browser.