pthread_barrier(3) - NetBSD Manual Pages

PTHREAD_BARRIER(3)      NetBSD Library Functions Manual     PTHREAD_BARRIER(3)


NAME
pthread_barrier -- barrier interface
LIBRARY
POSIX Threads Library (libpthread, -lpthread)
SYNOPSIS
#include <pthread.h> int pthread_barrier_init(pthread_barrier_t * restrict barrier, const pthread_barrierattr_t * restrict attr, unsigned int count); int pthread_barrier_destroy(pthread_barrier_t *barrier); int pthread_barrier_wait(pthread_barrier_t *barrier); int pthread_barrierattr_getpshared(const pthread_barrierattr_t * __restrict attr, int * __restrict pshared); int pthread_barrierattr_setpshared(pthread_barrierattr_t * attr, int pshared);
DESCRIPTION
The pthread_barrier_init() function creates a new barrier with attributes attr and count. The count parameter indicates the number of threads which will participate in the barrier. The pthread_barrierattr_init(3) function may be used to specify the attributes supplied in attr. If attr is NULL, the default attributes are used. Barriers are most commonly used in the decomposition of parallel loops. The pthread_barrier_destroy() function causes the resources allocated to barrier to be released. No threads should be blocked on barrier. The pthread_barrier_wait() function causes the current thread to wait on the barrier specified. Once as many threads as specified by the count parameter to the corresponding pthread_barrier_init() call have called pthread_barrier_wait(), all threads will wake up, return from their respective pthread_barrier_wait() calls and continue execution. The pthread_barrierattr_getpshared() function shall obtain the value of the process-shared attribute from the attributes object referenced by attr. The pthread_barrierattr_setpshared() function shall set the process-shared attribute in an initialized attributes object referenced by attr.
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. If successful, pthread_barrier_destroy() will return zero. Otherwise an error value will be returned. If successful, pthread_barrier_wait() will return zero for all waiting threads except for one. One thread will receive status PTHREAD_BARRIER_SERIAL_THREAD, which is intended to indicate that this thread may be used to update shared data. It is the responsibility of this thread to insure the visibility and atomicity of any updates to shared data with respect to the other threads participating in the bar- rier. In the case of failure, an error value will be returned. If successful, pthread_barrierattr_getpshared() shall return zero and store the value of the process-shared attribute of attr into the object referenced by the pshared parameter. Otherwise, an error number shall be returned to indicate the error. If successful, pthread_barrierattr_setpshared() shall return zero; Other- wise, an error number shall be returned to indicate the error.
ERRORS
The pthread_barrier_init() function may fail if: [EINVAL] The value specified by count is zero or attr is invalid. The pthread_barrier_destroy() function may fail if: [EBUSY] The barrier still has active threads associated with it. [EINVAL] The value specified by barrier is invalid. The pthread_barrier_wait() function may fail if: [EINVAL] The value specified by barrier is invalid. The pthread_barrierattr_setpshared() function and the pthread_barrierattr_getpshared() function may fail if: [EINVAL] The value specified by attr is invalid.
SEE ALSO
pthread_barrierattr(3), pthread_cond(3), pthread_mutex(3)
STANDARDS
These functions conform to IEEE Std 1003.1-2001 (``POSIX.1'').
BUGS
The pthread_barrierattr_getpshared() and pthread_barrierattr_setpshared() functions are hidden by default since only thread shared attributes are supported. NetBSD 8.2 June 12, 2016 NetBSD 8.2

Powered by man-cgi (2024-08-26). Maintained for NetBSD by Kimmo Suominen. Based on man-cgi by Panagiotis Christias.