pthread_barrier.h File Reference

Synchronization barriers. More...

Detailed Description

Synchronization barriers.

Note
Do not include this header file directly, but pthread.h.

Definition in file pthread_barrier.h.

#include "mutex.h"
+ Include dependency graph for pthread_barrier.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pthread_barrier_waiting_node
 Internal structure to store the list of waiting threads. More...
 
struct  pthread_barrier_t
 A synchronization barrier. More...
 
struct  pthread_barrierattr_t
 Details for a pthread_barrier_t. More...
 
#define PTHREAD_PROCESS_SHARED   (0)
 Share the structure with child processes (default). More...
 
#define PTHREAD_PROCESS_PRIVATE   (1)
 Don't share the structure with child processes. More...
 
typedef struct pthread_barrier_waiting_node pthread_barrier_waiting_node_t
 Internal structure to store the list of waiting threads.
 
int pthread_barrier_init (pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count)
 Initializes a pthread_barrier_t. More...
 
int pthread_barrier_destroy (pthread_barrier_t *barrier)
 Destroys a pthread_barrier_t. More...
 
int pthread_barrier_wait (pthread_barrier_t *barrier)
 Waiting on a synchronization barrier. More...
 
int pthread_barrierattr_init (pthread_barrierattr_t *attr)
 Initialize a pthread_barrierattr_t. More...
 
int pthread_barrierattr_destroy (pthread_barrierattr_t *attr)
 Destroy a pthread_barrierattr_t. More...
 
int pthread_barrierattr_getpshared (const pthread_barrierattr_t *attr, int *pshared)
 Returns whether the barrier attribute was set to be shared. More...
 
int pthread_barrierattr_setpshared (pthread_barrierattr_t *attr, int pshared)
 Set if the barrier should be shared with child processes. More...
 

Macro Definition Documentation

◆ PTHREAD_PROCESS_PRIVATE

#define PTHREAD_PROCESS_PRIVATE   (1)

Don't share the structure with child processes.

Note
RIOT is a single-process OS. Setting the value of pshared does not change anything.

Definition at line 39 of file pthread_barrier.h.

◆ PTHREAD_PROCESS_SHARED

#define PTHREAD_PROCESS_SHARED   (0)

Share the structure with child processes (default).

Note
RIOT is a single-process OS. Setting the value of pshared does not change anything.

Definition at line 32 of file pthread_barrier.h.

Function Documentation

◆ pthread_barrier_destroy()

int pthread_barrier_destroy ( pthread_barrier_t barrier)

Destroys a pthread_barrier_t.

To use the barrier again you will need to call pthread_barrier_init() again. Destroying a barrier while threads are currently waiting for it causes indefined behavior.

Parameters
barrierBarrier to destoy
Returns
0, the invocation cannot fail

◆ pthread_barrier_init()

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

Initializes a pthread_barrier_t.

Parameters
barrierDatum to initialize
attr(unused)
countNumber of thread to wait for
Returns
0, the invocation cannot fail

◆ pthread_barrier_wait()

int pthread_barrier_wait ( pthread_barrier_t barrier)

Waiting on a synchronization barrier.

The barrier need to be initialized with pthread_barrier_init().

Parameters
barrierBarrier to wait for
Returns
0, the invocation cannot fail

◆ pthread_barrierattr_destroy()

int pthread_barrierattr_destroy ( pthread_barrierattr_t attr)

Destroy a pthread_barrierattr_t.

This function does nothing.

Parameters
attrDatum to destroy
Returns
0, the invocation cannot fail

◆ pthread_barrierattr_getpshared()

int pthread_barrierattr_getpshared ( const pthread_barrierattr_t attr,
int *  pshared 
)

Returns whether the barrier attribute was set to be shared.

Parameters
attrBarrier attribute to read
psharedThe value previously stored with pthread_barrierattr_setpshared().
Returns
0, the invocation cannot fail

◆ pthread_barrierattr_init()

int pthread_barrierattr_init ( pthread_barrierattr_t attr)

Initialize a pthread_barrierattr_t.

A zeroed out datum is initialized.

Parameters
attrDatum to initialize.
Returns
0, the invocation cannot fail

◆ pthread_barrierattr_setpshared()

int pthread_barrierattr_setpshared ( pthread_barrierattr_t attr,
int  pshared 
)

Set if the barrier should be shared with child processes.

Since RIOT is a single process OS, pthread_barrier_init() will ignore the value.

Parameters
attrAttribute set for pthread_barrier_init()
psharedEither PTHREAD_PROCESS_PRIVATE or PTHREAD_PROCESS_SHARED
Returns
0, the invocation cannot fail