1PTHREAD_BARRIER_WAIT(3P) POSIX Programmer's Manual PTHREAD_BARRIER_WAIT(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 pthread_barrier_wait — synchronize at a barrier
14
16 #include <pthread.h>
17
18 int pthread_barrier_wait(pthread_barrier_t *barrier);
19
21 The pthread_barrier_wait() function shall synchronize participating
22 threads at the barrier referenced by barrier. The calling thread shall
23 block until the required number of threads have called pthread_bar‐
24 rier_wait() specifying the barrier.
25
26 When the required number of threads have called pthread_barrier_wait()
27 specifying the barrier, the constant PTHREAD_BARRIER_SERIAL_THREAD
28 shall be returned to one unspecified thread and zero shall be returned
29 to each of the remaining threads. At this point, the barrier shall be
30 reset to the state it had as a result of the most recent pthread_bar‐
31 rier_init() function that referenced it.
32
33 The constant PTHREAD_BARRIER_SERIAL_THREAD is defined in <pthread.h>
34 and its value shall be distinct from any other value returned by
35 pthread_barrier_wait().
36
37 The results are undefined if this function is called with an uninitial‐
38 ized barrier.
39
40 If a signal is delivered to a thread blocked on a barrier, upon return
41 from the signal handler the thread shall resume waiting at the barrier
42 if the barrier wait has not completed (that is, if the required number
43 of threads have not arrived at the barrier during the execution of the
44 signal handler); otherwise, the thread shall continue as normal from
45 the completed barrier wait. Until the thread in the signal handler
46 returns from it, it is unspecified whether other threads may proceed
47 past the barrier once they have all reached it.
48
49 A thread that has blocked on a barrier shall not prevent any unblocked
50 thread that is eligible to use the same processing resources from even‐
51 tually making forward progress in its execution. Eligibility for pro‐
52 cessing resources shall be determined by the scheduling policy.
53
55 Upon successful completion, the pthread_barrier_wait() function shall
56 return PTHREAD_BARRIER_SERIAL_THREAD for a single (arbitrary) thread
57 synchronized at the barrier and zero for each of the other threads.
58 Otherwise, an error number shall be returned to indicate the error.
59
61 This function shall not return an error code of [EINTR].
62
63 The following sections are informative.
64
66 None.
67
69 Applications using this function may be subject to priority inversion,
70 as discussed in the Base Definitions volume of POSIX.1‐2008, Section
71 3.287, Priority Inversion.
72
74 If an implementation detects that the value specified by the barrier
75 argument to pthread_barrier_wait() does not refer to an initialized
76 barrier object, it is recommended that the function should fail and
77 report an [EINVAL] error.
78
80 None.
81
83 pthread_barrier_destroy()
84
85 The Base Definitions volume of POSIX.1‐2008, Section 3.287, Priority
86 Inversion, Section 4.11, Memory Synchronization, <pthread.h>
87
89 Portions of this text are reprinted and reproduced in electronic form
90 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
91 -- Portable Operating System Interface (POSIX), The Open Group Base
92 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
93 cal and Electronics Engineers, Inc and The Open Group. (This is
94 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
95 event of any discrepancy between this version and the original IEEE and
96 The Open Group Standard, the original IEEE and The Open Group Standard
97 is the referee document. The original Standard can be obtained online
98 at http://www.unix.org/online.html .
99
100 Any typographical or formatting errors that appear in this page are
101 most likely to have been introduced during the conversion of the source
102 files to man page format. To report such errors, see https://www.ker‐
103 nel.org/doc/man-pages/reporting_bugs.html .
104
105
106
107IEEE/The Open Group 2013 PTHREAD_BARRIER_WAIT(3P)