NAME
pthread_barrier_init,
pthread_barrier_destroy —
initialize and destroy a barrier
object
SYNOPSIS
#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);
DESCRIPTION
The
pthread_barrier_init()
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
pthread_barrier_wait()
function to check if the required number of threads reached the barrier.
The
pthread_barrier_destroy()
function frees the resources allocated for
barrier.
RETURN VALUES
If successful, pthread_barrier_init() and
pthread_barrier_destroy() return zero; otherwise an
error number is returned to indicate the error.
ERRORS
pthread_barrier_init() will fail if:
- [
EINVAL] - The value specified by barrier or attr is invalid.
- [
ENOMEM] - The process cannot allocate enough memory to create another barrier object.
- [
ENOTSUP] - The attributes specified by attr are not supported by the current implementation.
pthread_barrier_destroy() will fail
if:
- [
EINVAL] - The value specified by barrier is invalid.
- [
EBUSY] - There are still threads waiting on the barrier.
SEE ALSO
pthread_barrier_wait(3), pthread_barrierattr_getpshared(3), pthread_barrierattr_init(3)
STANDARDS
pthread_barrier_init() and
pthread_barrier_destroy() conform to
IEEE Std 1003.1-2008 (“POSIX.1”).
BUGS
Currently only private barriers are supported and the pshared
attribute is always set that way. Any attempts to change that value will
trigger ENOTSUP.