pthread_barrier.h

Synchronization barriers.

Note

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

PTHREAD_PROCESS_SHARED

Share the structure with child processes (default).

1
(0)

Note

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

PTHREAD_PROCESS_PRIVATE

Don’t share the structure with child processes.

1
(1)

Note

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

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.

Parameters

barrier:Datum to initialize
attr:(unused)
count:Number of thread to wait for

Return values

  • 0, the invocation cannot fail
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.h::pthread_barrier_init() again. Destroying a barrier while threads are currently waiting for it causes indefined behavior.

Parameters

barrier:Barrier to destoy

Return values

  • 0, the invocation cannot fail
int pthread_barrier_wait(pthread_barrier_t * barrier)

Waiting on a synchronization barrier.

The barrier need to be initialized with pthread_barrier.h::pthread_barrier_init().

Parameters

barrier:Barrier to wait for

Return values

  • 0, the invocation cannot fail
int pthread_barrierattr_init(pthread_barrierattr_t * attr)

Initialize a pthread_barrierattr_t.

A zeroed out datum is initialized.

Parameters

attr:Datum to initialize.

Return values

  • 0, the invocation cannot fail
int pthread_barrierattr_destroy(pthread_barrierattr_t * attr)

Destroy a pthread_barrierattr_t.

This function does nothing.

Parameters

attr:Datum to destroy

Return values

  • 0, the invocation cannot fail
int pthread_barrierattr_getpshared(const pthread_barrierattr_t * attr, int * pshared)

Returns whether the barrier attribute was set to be shared.

Parameters

attr:Barrier attribute to read
pshared:The value previously stored with pthread_barrier.h::pthread_barrierattr_setpshared().

Return values

  • 0, the invocation cannot fail
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.h::pthread_barrier_init() wil ignore the value.

Parameters

attr:Attribute set for pthread_barrier.h::pthread_barrier_init()
pshared:Either pthread_barrier.h::PTHREAD_PROCESS_PRIVATE or pthread_barrier.h::PTHREAD_PROCESS_SHARED

Return values

  • 0, the invocation cannot fail
struct pthread_barrier_waiting_node

Internal structure to store the list of waiting threads.

struct pthread_barrier_waiting_node * next

The next waiting thread.

kernel_types.h::kernel_pid_t pid

The current thread to wake up.

int cont

0 = spurious wake up, 1 = wake up

struct pthread_barrier_t

A synchronization barrier.

Initialize with pthread_barrier.h::pthread_barrier_init(). For a zeroed out datum you do not need to call the initializer, it is enough to set pthread_barrier.h::pthread_barrier_t::count.

struct pthread_barrier_waiting_node * next

The first waiting thread.

mutex_t mutex

Mutex to unlock to wake the thread up.

int count

Wait for N more threads before waking everyone up.

struct pthread_barrierattr_t

Details for a pthread_barrier_t.

RIOT does not need this structure, because it is a single process OS. This is only here to POSIX compatibility.

int pshared

See pthread_barrier.h::pthread_barrierattr_setpshared() and pthread_barrier.h::pthread_barrierattr_getpshared().