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