1PTHREAD_BARRIER_DESTROY(P) POSIX Programmer's ManualPTHREAD_BARRIER_DESTROY(P)
2
3
4
6 pthread_barrier_destroy, pthread_barrier_init - destroy and initialize
7 a barrier object (ADVANCED REALTIME THREADS)
8
10 #include <pthread.h>
11
12 int pthread_barrier_destroy(pthread_barrier_t *barrier);
13 int pthread_barrier_init(pthread_barrier_t *restrict barrier,
14 const pthread_barrierattr_t *restrict attr, unsigned count);
15
16
18 The pthread_barrier_destroy() function shall destroy the barrier refer‐
19 enced by barrier and release any resources used by the barrier. The
20 effect of subsequent use of the barrier is undefined until the barrier
21 is reinitialized by another call to pthread_barrier_init(). An imple‐
22 mentation may use this function to set barrier to an invalid value. The
23 results are undefined if pthread_barrier_destroy() is called when any
24 thread is blocked on the barrier, or if this function is called with an
25 uninitialized barrier.
26
27 The pthread_barrier_init() function shall allocate any resources
28 required to use the barrier referenced by barrier and shall initialize
29 the barrier with attributes referenced by attr. If attr is NULL, the
30 default barrier attributes shall be used; the effect is the same as
31 passing the address of a default barrier attributes object. The results
32 are undefined if pthread_barrier_init() is called when any thread is
33 blocked on the barrier (that is, has not returned from the pthread_bar‐
34 rier_wait() call). The results are undefined if a barrier is used with‐
35 out first being initialized. The results are undefined if pthread_bar‐
36 rier_init() is called specifying an already initialized barrier.
37
38 The count argument specifies the number of threads that must call
39 pthread_barrier_wait() before any of them successfully return from the
40 call. The value specified by count must be greater than zero.
41
42 If the pthread_barrier_init() function fails, the barrier shall not be
43 initialized and the contents of barrier are undefined.
44
45 Only the object referenced by barrier may be used for performing syn‐
46 chronization. The result of referring to copies of that object in calls
47 to pthread_barrier_destroy() or pthread_barrier_wait() is undefined.
48
50 Upon successful completion, these functions shall return zero; other‐
51 wise, an error number shall be returned to indicate the error.
52
54 The pthread_barrier_destroy() function may fail if:
55
56 EBUSY The implementation has detected an attempt to destroy a barrier
57 while it is in use (for example, while being used in a
58 pthread_barrier_wait() call) by another thread.
59
60 EINVAL The value specified by barrier is invalid.
61
62
63 The pthread_barrier_init() function shall fail if:
64
65 EAGAIN The system lacks the necessary resources to initialize another
66 barrier.
67
68 EINVAL The value specified by count is equal to zero.
69
70 ENOMEM Insufficient memory exists to initialize the barrier.
71
72
73 The pthread_barrier_init() function may fail if:
74
75 EBUSY The implementation has detected an attempt to reinitialize a
76 barrier while it is in use (for example, while being used in a
77 pthread_barrier_wait() call) by another thread.
78
79 EINVAL The value specified by attr is invalid.
80
81
82 These functions shall not return an error code of [EINTR].
83
84 The following sections are informative.
85
87 None.
88
90 The pthread_barrier_destroy() and pthread_barrier_init() functions are
91 part of the Barriers option and need not be provided on all implementa‐
92 tions.
93
95 None.
96
98 None.
99
101 pthread_barrier_wait() , the Base Definitions volume of
102 IEEE Std 1003.1-2001, <pthread.h>
103
105 Portions of this text are reprinted and reproduced in electronic form
106 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
107 -- Portable Operating System Interface (POSIX), The Open Group Base
108 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
109 Electrical and Electronics Engineers, Inc and The Open Group. In the
110 event of any discrepancy between this version and the original IEEE and
111 The Open Group Standard, the original IEEE and The Open Group Standard
112 is the referee document. The original Standard can be obtained online
113 at http://www.opengroup.org/unix/online.html .
114
115
116
117IEEE/The Open Group 2003 PTHREAD_BARRIER_DESTROY(P)