File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 12041204\item The barrier API has been defined since SUSv3, see for example
12051205\texttt {pthread\_\- barrier\_ init }, however they can be created using
12061206mutexes and condition variables.
1207- \item The barrier API is non-mandatory part of POSIXu (it belongs to
1207+ \item The barrier API is non-mandatory part of POSIX (it belongs to
12081208Advanced realtime threads extension) and hence SUS certified system does not
12091209have to implement it, which is e.g. the case of macOS.
12101210\item The barrier can be used e.g. in situation when it is necessary to perform
12111211some initialization between individual phases of processing. The threads
12121212need to wait for each other because the initialization can only begin
12131213once the previous phase is over.
12141214Example \example {pthreads/pthread-barrier.c} shows the use in such case.
1215+ \item \texttt {pthread\_ barrier\_ wait } returns
1216+ the \texttt {PTHREAD\_ BARRIER\_ SERIAL\_ THREAD } value
1217+ in the last thread that reached the barrier so e.g. a collection of
1218+ results from the last phase of the run can be done.
12151219\item The barrier condition is for example value of a counter to be 0.
12161220Each thread that reaches the barrier decrements the counter which is
12171221initialized to the number of threads in the beginning.
You can’t perform that action at this time.
0 commit comments