OpenBSD manual page server

Manual Page Search Parameters

PTHREAD_BARRIER_INIT(3) Library Functions Manual PTHREAD_BARRIER_INIT(3)

pthread_barrier_init, pthread_barrier_destroyinitialize and destroy a barrier object

#include <pthread.h>

int
pthread_barrier_init(pthread_barrier_t *barrier, pthread_barrierattr_t *attr, unsigned int count);

int
pthread_barrier_destroy(pthread_barrier_t *barrier);

The () function creates a new barrier object, with attributes specified with attr and with a threshold specified with count. If attr is NULL the default attributes are used. The count argument is later used by the () function to check if the required number of threads reached the barrier.

The () function frees the resources allocated for barrier.

If successful, pthread_barrier_init() and pthread_barrier_destroy() return zero; otherwise an error number is returned to indicate the error.

pthread_barrier_init() will fail if:

[]
The value specified by barrier or attr is invalid.
[]
The process cannot allocate enough memory to create another barrier object.
[]
The attributes specified by attr are not supported by the current implementation.

pthread_barrier_destroy() will fail if:

[]
The value specified by barrier is invalid.
[]
There are still threads waiting on the barrier.

pthread_barrier_wait(3), pthread_barrierattr_getpshared(3), pthread_barrierattr_init(3)

pthread_barrier_init() and pthread_barrier_destroy() conform to IEEE Std 1003.1-2008 (“POSIX.1”).

Currently only private barriers are supported and the pshared attribute is always set that way. Any attempts to change that value will trigger ENOTSUP.

June 5, 2013 OpenBSD-6.5