FreeRTOS: POSIX
Return to main page ↑
FreeRTOS_POSIX_pthread_barrier.c File Reference

Implementation of barrier functions in pthread.h. More...

#include <stddef.h>
#include "FreeRTOS_POSIX.h"
#include "FreeRTOS_POSIX/errno.h"
#include "FreeRTOS_POSIX/pthread.h"
#include "atomic.h"

Macros

#define posixPTHREAD_BARRIER_MAX_COUNT   ( 24 )
 

Functions

int pthread_barrier_destroy (pthread_barrier_t *barrier)
 Destroy a barrier object. More...
 
int pthread_barrier_init (pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned count)
 Initialize a barrier object. More...
 
int pthread_barrier_wait (pthread_barrier_t *barrier)
 Synchronize at a barrier. More...
 

Detailed Description

Implementation of barrier functions in pthread.h.

Function Documentation

◆ pthread_barrier_destroy()

int pthread_barrier_destroy ( pthread_barrier_t barrier)

Destroy a barrier object.

See also
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_barrier_destroy.html
Return values
0- Upon successful completion.
Note
This function does not validate whether there is any thread blocking on the barrier before destroying.

◆ pthread_barrier_init()

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

Initialize a barrier object.

See also
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_barrier_init.html
Return values
0- Upon successful completion.
EINVAL- The value specified by count is equal to zero.
ENOMEM- count cannot fit into FreeRTOS event group type OR insufficient memory exists to initialize the barrier.
Note
attr is ignored.
pthread_barrier_init() is implemented with FreeRTOS event group. To ensure count fits in event group, count may be at most 8 when configUSE_16_BIT_TICKS is 1; it may be at most 24 otherwise. configUSE_16_BIT_TICKS is configured in application FreeRTOSConfig.h file, which defines how many bits tick count type has. See further details and limitation about event group and configUSE_16_BIT_TICKS in FreeRTOS site.

◆ pthread_barrier_wait()

int pthread_barrier_wait ( pthread_barrier_t barrier)

Synchronize at a barrier.

See also
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_barrier_wait.html
Return values
PTHREAD_BARRIER_SERIAL_THREAD- Upon successful completion, the first thread.
0- Upon successful completion, other thread(s).