Skip to content

Commit 6bcac4b

Browse files
author
Vladimir Kotal
committed
describe PTHREAD_BARRIER_SERIAL_THREAD
1 parent 7d8fa6c commit 6bcac4b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

threads.tex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,14 +1204,18 @@
12041204
\item The barrier API has been defined since SUSv3, see for example
12051205
\texttt{pthread\_\-barrier\_init}, however they can be created using
12061206
mutexes 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
12081208
Advanced realtime threads extension) and hence SUS certified system does not
12091209
have 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
12111211
some initialization between individual phases of processing. The threads
12121212
need to wait for each other because the initialization can only begin
12131213
once the previous phase is over.
12141214
Example \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.
12161220
Each thread that reaches the barrier decrements the counter which is
12171221
initialized to the number of threads in the beginning.

0 commit comments

Comments
 (0)