January 30, 2003 PTHREAD_BARRIER_INIT 3

### NAME

pthread_barrier_init - create a barrier

### LIBRARY

POSIX Thread Library (libpthread, -lpthread)

### SYNOPSIS

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

### DESCRIPTION

The pthread_barrier_init(``) function creates a new barrier, with attributes specified with ```attr` and ```count`. The ```count` parameter indicates the number of threads which will participate in the barrier. If ```attr` is NULL the default attributes are used. Barriers are most commonly used in the decomposition of parallel loops.

### RETURN VALUES

If successful, pthread_barrier_init(``) will return zero and put the new barrier id into ```barrier`, otherwise an error number will be returned to indicate the error.

### ERRORS

pthread_barrier_init(``) shall fail if:

[```EAGAIN`]
  The system lacks the resources to initialize another barrier.

[```EINVAL`]
  The value specified by ```count` is zero.

[```ENOMEM`]
  Insufficient memory exists to initialize the barrier.

pthread_barrier_init(``) may fail if:

[```EBUSY`]
  The barrier structure has been initialized already.

[```EINVAL`]
  The value specified by ```attr` is invalid.

### SEE ALSO

pthread_barrier_destroy(3), pthread_barrier_wait(3), pthread_barrierattr_destroy(3), pthread_barrierattr_init(3)

### STANDARDS

pthread_barrier_init(``) conforms to IEEE Std 1003.1-2001 (``POSIX.1'') .