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

Implementation of condition variable functions in pthread.h. More...

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

Functions

static void prvInitializeStaticCond (pthread_cond_internal_t *pxCond)
 Initialize a PTHREAD_COND_INITIALIZER cond. More...
 
static void prvTestAndDecrement (pthread_cond_t *pxCond, unsigned iLocalWaitingThreads)
 Check "atomically" if iLocalWaitingThreads == pxCond->iWaitingThreads and decrement.
 
int pthread_cond_broadcast (pthread_cond_t *cond)
 Broadcast a condition. More...
 
int pthread_cond_destroy (pthread_cond_t *cond)
 Destroy condition variables. More...
 
int pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr)
 Initialize condition variables. More...
 
int pthread_cond_signal (pthread_cond_t *cond)
 Signal a condition. More...
 
int pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
 Wait on a condition with a timeout. More...
 
int pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex)
 Wait on a condition. More...
 

Detailed Description

Implementation of condition variable functions in pthread.h.

Function Documentation

◆ prvInitializeStaticCond()

static void prvInitializeStaticCond ( pthread_cond_internal_t *  pxCond)
static

Initialize a PTHREAD_COND_INITIALIZER cond.

PTHREAD_COND_INITIALIZER sets a flag for a cond to be initialized later. This function performs the initialization.

Parameters
[in]pxCondThe cond to initialize.
Returns
nothing

◆ pthread_cond_broadcast()

int pthread_cond_broadcast ( pthread_cond_t cond)

Broadcast a condition.

See also
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_broadcast.html
Return values
0- Upon successful completion.

◆ pthread_cond_destroy()

int pthread_cond_destroy ( pthread_cond_t cond)

Destroy condition variables.

See also
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_destroy.html
Return values
0- Upon successful completion.

◆ pthread_cond_init()

int pthread_cond_init ( pthread_cond_t cond,
const pthread_condattr_t attr 
)

Initialize condition variables.

See also
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_init.html
Return values
0- Upon successful completion.
ENOMEM- Insufficient memory exists to initialize the condition variable.
Note
attr is ignored and treated as NULL. Default setting is always used.

◆ pthread_cond_signal()

int pthread_cond_signal ( pthread_cond_t cond)

Signal a condition.

See also
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_signal.html
Return values
0- Upon successful completion.

◆ pthread_cond_timedwait()

int pthread_cond_timedwait ( pthread_cond_t cond,
pthread_mutex_t mutex,
const struct timespec abstime 
)

Wait on a condition with a timeout.

See also
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_timedwait.html
Return values
0- Upon successful completion.
EINVAL- The abstime argument passed in does not refer to an initialized structure OR the abstime parameter specified a nanoseconds field value less than zero or greater than or equal to 1000 million.
ETIMEDOUT- The time specified by abstime to pthread_cond_timedwait() has passed.

◆ pthread_cond_wait()

int pthread_cond_wait ( pthread_cond_t cond,
pthread_mutex_t mutex 
)

Wait on a condition.

See also
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_wait.html
Return values
0- Upon successful completion.