pthread_barrier_init() returns zero after completing successfully. Any other return value indicates that an error occurred. If the following condition occurs, the function fails and returns the corresponding value.
The value specified by count is equal to 0, or the value specified by attr is invalid
The system lacks the necessary resources to initialize another barrier.
Insufficient memory exists to initialize the barrier.
There was an attempt to destroy a barrier while it is in use (for example, while being used in a pthread_barrier_wait() call) by another thread.