[Previous] [Contents] [Next]

pthread_barrier_init()

Initialize a barrier object

Synopsis:

#include <pthread.h>

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

Library:

libc

Description:

The pthread_barrier_init() function allocates any resources required to use the barrier referenced by barrier and initializes the barrier with attributes referenced by attr. If attr is NULL, the default barrier attributes are used. The effect is the same as passing the address of a default barrier attributes object. Once initialized, the barrier can be used any number of times without being reinitialized.

If pthread_barrier_init() fails, the barrier isn't initialized.

The count argument specifies the number of threads that must call barrier_wait() before any of them successfully returns from the call. The value specified by count must be greater than zero.

In cases where default barrier attributes are appropriate, the PTHREAD_BARRIER_INITIALIZER() macro can be used to initialize barriers that are statically allocated. The effect is equivalent to dynamic initialization by a call to pthread_barrier_init() with parameter attr specified as NULL, except that no error checks are performed.

Returns:

EAGAIN
The system lacks the necessary resources to initialize another barrier.
EBUSY
Attempt to reinitialize a barrier while it's in use.
EFAULT
A fault occurred when the kernel tried to access barrier or attr.
EINVAL
Invalid value specified by attr.
EOK
Success.

Classification:

POSIX 1003.1j (draft)

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

pthread_barrierattr_init(), pthread_barrier_destroy(), pthread_barrier_wait()


[Previous] [Contents] [Next]