The
pthread_barrier_init() function creates a new barrier with attributes
attr and
count. The
count parameter indicates the number of threads which will participate in the barrier. The
pthread_barrierattr_init(3) function may be used to specify the attributes supplied in
attr. If
attr is
NULL, the default attributes are used. Barriers are most commonly used in the decomposition of parallel loops.
The
pthread_barrier_destroy() function causes the resources allocated to
barrier to be released. No threads should be blocked on
barrier.
The
pthread_barrier_wait() function causes the current thread to wait on the barrier specified. Once as many threads as specified by the
count parameter to the corresponding
pthread_barrier_init() call have called
pthread_barrier_wait(), all threads will wake up, return from their respective
pthread_barrier_wait() calls and continue execution.