NAME

pthread_barrier_destroy, pthread_barrier_init, pthread_barrier_wait: destroy, initialize or wait on a barrier object

SYNOPSIS

#include <pthread.h>

int pthread_barrier_init (pthread_barrier_t *barrier , const pthread_barrierattr *attr ,
unsigned count );
int pthread_barrier_destroy (pthread_barrier_t *barrier);
int pthread_barrier_wait (pthread_barrier_t *barrier);
typedef struct {
...
} pthread_barrier_t;
typedef struct {
...
} pthread_barrierattr;

DESCRIPTION

A barrier is used to synchronize multiple threads at a specific point in the program. A typical application might be dividing up a data collection and assigning one thread to each part of the data. When all data is processed, all threads synchronize and the processed data can be passed on as a whole.

pthread_barrier_init() creates and initializes the barrier specified by the attributes, with the expected threads count, returning zero if successful.

pthread_barrier_destroy will destroy the barrier and release any resources. It returns zero if successful.

pthread_barrier_wait synchronizes count threads at the barrier, releasing them all when all have arrived. The final thread returns PTHREAD_BARRIER_SERIAL_THREAD.

ERRORS

EINVAL

pthread_barrier_init():

The named barrier is invalid or the count is less than or equal to zero

pthread_barrier_destroy(), pthread_barrier_wait():

The value specified is invalid.

EBUSY

pthread_barrier_destroy():

The threads have not all called and continued from the barrier so it cannot be destroyed.

SEE ALSO

pthread_join(),

Home page (Kernel)


< Copyright Rowebots Research Inc. and Multiprocessor Toolsmiths Inc. 1987-2018 >