Multithreaded Programming Guide

Setting a Barrier Process-Shared Attribute

The pthread_barrierattr_setpshared() function sets the process-shared attribute in an initialized attributes object referenced by attr. The process-shared attribute can have the following values:


The barrier can only be operated upon by threads created within the same process as the thread that initialized the barrier. This is the default value of the process-shared attribute.


The barrier can be operated upon by any thread that has access to the memory where the barrier is allocated.

pthread_barrierattr_setpshared() Syntax

int pthread_barrierattr_setpshared(pthread_barrierattr_t *attr, int pshared);

pthread_barrierattr_setpshared() Return Values

pthread_barrierattr_setpshared() 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.



Indicates that the value of attr was not valid, or the new value specified for the pshared is not valid.