pthread_barrier_destroy(), pthread_barrier_init()

destroy and initialize a barrier object 

Advanced Realtime Threads


SYNOPSIS

#include <pthread.h>

int pthread_barrier_destroy(pthread_barrier_t *barrier);

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


DESCRIPTION

The pthread_barrier_destroy() function destroys the barrier pointed to by the barrier argument. It also releases the resources used by that barrier. Once a barrier has been destroyed, it should be reinitialized by a pthread_barrier_init() call before it is used again.

The pthread_barrier_init() function allocates the resources needed for the specified barrier and initializes that barrier with the attributes pointed to by the attr argument. When attr is NULL, the specified barrier is initialized with the default attributes. You should always initialize a barrier with this function before making any other reference to that barrier.

The count argument to pthread_barrier_init() indicates how many threads must call the pthread_barrier_wait() function before any of those threads successfully return from the call. count must be greater than zero.

When the pthread_barrier_init() function fails, the specified barrier is not initialized.

You should only use the object pointed to by barrier to perform synchronization. Using copies of that object with pthread_barrier_destroy() or pthread_barrier_wait() may not produce the desired results.


PARAMETERS

attr 

Points to the attributes to be used when initializing a barrier with pthread_barrier_init().

barrier 

Points to the barrier to be destroyed by pthread_barrier_destroy() or initialized by pthread_barrier_init().

count 

Indicates how many threads (minimum of one) must call the pthread_barrier_wait() function before any of those threads successfully return from the call.


RETURN VALUES

When successful, the pthread_barrier_destroy() function returns zero. Otherwise, it returns one of the following:

EBUSY 

An attempt to destroy a barrier occurred while another thread was using the barrier (for example, in a pthread_barrier_wait() call).

EINVAL 

The barrier argument is an invalid value.

When successful, the pthread_barrier_init() function returns zero. Otherwise, it returns one of the following:

EAGAIN 

Another barrier could not be initialized due to a lack of necessary resources.

EINVAL 

The count argument is equal to zero.

ENOMEM 

There is not enough available memory to initialize the barrier.

EBUSY 

An attempt to reinitialize a barrier occurred while another thread was using the barrier (for example, in a pthread_barrier_wait() call).

EINVAL 

The attr attribute points to an invalid value.


CONFORMANCE

UNIX 03.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
pthread_barrier_wait()


PTC MKS Toolkit 10.4 Documentation Build 39.