IntrOS
Loading...
Searching...
No Matches
Condition variable

condition variables More...

Macros

#define cndOne   ( false )
 notify one task
#define cndAll   ( true )
 notify all tasks (broadcast)
#define OS_CND(cnd)
 define and initialize a condition variable object
#define static_CND(cnd)
 static alias of OS_CND()
#define CND_INIT()
 create and initialize a condition variable object
#define CND_CREATE()
 create and initialize a condition variable object
#define CND_NEW   CND_CREATE
 alias of CND_CREATE()

Functions

void cnd_init (cnd_t *cnd)
 initialize a condition variable object
void cnd_reset (cnd_t *cnd)
 reset the condition variable object and wake up all waiting tasks with 'E_STOPPED' event value
void cnd_kill (cnd_t *cnd)
 alias of cnd_reset()
int cnd_waitFor (cnd_t *cnd, mtx_t *mtx, cnt_t delay)
 wait for given duration of time on the condition variable releasing the currently owned mutex, and finally lock the mutex again
int cnd_waitUntil (cnd_t *cnd, mtx_t *mtx, cnt_t time)
 wait until given timepoint on the condition variable releasing the currently owned mutex, and finally lock the mutex again
int cnd_wait (cnd_t *cnd, mtx_t *mtx)
 wait indefinitely on the condition variable releasing the currently owned mutex, and finally lock the mutex again
void cnd_give (cnd_t *cnd, bool all)
 signal one or all tasks that are waiting on the condition variable
void cnd_notifyOne (cnd_t *cnd)
 signal one task waiting on the condition variable
void cnd_notifyAll (cnd_t *cnd)
 signal all tasks waiting on the condition variable

Detailed Description

condition variables

Macro Definition Documentation

◆ OS_CND

#define OS_CND ( cnd)
Value:
cnd_t cnd[] = { _CND_INIT() }

define and initialize a condition variable object

Parameters
cndname of a pointer to condition variable object

◆ static_CND

#define static_CND ( cnd)
Value:
static cnd_t cnd[] = { _CND_INIT() }

static alias of OS_CND()

◆ CND_INIT

#define CND_INIT ( )
Value:
_CND_INIT()

create and initialize a condition variable object

Returns
condition variable object
Note
use only in 'C' code

◆ CND_CREATE

#define CND_CREATE ( )
Value:
{ CND_INIT () }
#define CND_INIT()
create and initialize a condition variable object
Definition osconditionvariable.h:100

create and initialize a condition variable object

Returns
condition variable object as array (id)
Note
use only in 'C' code

Function Documentation

◆ cnd_init()

void cnd_init ( cnd_t * cnd)

initialize a condition variable object

Parameters
cndpointer to condition variable object

◆ cnd_reset()

void cnd_reset ( cnd_t * cnd)

reset the condition variable object and wake up all waiting tasks with 'E_STOPPED' event value

Parameters
cndpointer to condition variable object
Note
use only in thread mode

◆ cnd_waitFor()

int cnd_waitFor ( cnd_t * cnd,
mtx_t * mtx,
cnt_t delay )

wait for given duration of time on the condition variable releasing the currently owned mutex, and finally lock the mutex again

Parameters
cndpointer to condition variable object
mtxcurrently owned mutex
delayduration of time (maximum number of ticks to wait on the condition variable object)
  • IMMEDIATE: don't wait on the condition variable object
  • INFINITE: wait indefinitely on the condition variable object
Return values
E_SUCCESScondition variable object was successfully signalled; owned mutex was locked again
E_FAILUREmutex object can't be unlocked
E_STOPPEDcondition variable or mutex object was reseted
E_TIMEOUTcondition variable object was not signalled before the specified timeout expired; owned mutex was locked again

◆ cnd_waitUntil()

int cnd_waitUntil ( cnd_t * cnd,
mtx_t * mtx,
cnt_t time )

wait until given timepoint on the condition variable releasing the currently owned mutex, and finally lock the mutex again

Parameters
cndpointer to condition variable object
mtxcurrently owned mutex
timetimepoint value
Return values
E_SUCCESScondition variable object was successfully signalled; owned mutex was locked again
E_FAILUREmutex object can't be unlocked
E_STOPPEDcondition variable or mutex object was reseted
E_TIMEOUTcondition variable object was not signalled before the specified timeout expired; owned mutex was locked again

◆ cnd_wait()

int cnd_wait ( cnd_t * cnd,
mtx_t * mtx )
inline

wait indefinitely on the condition variable releasing the currently owned mutex, and finally lock the mutex again

Parameters
cndpointer to condition variable object
mtxcurrently owned mutex
Return values
E_SUCCESScondition variable object was successfully signalled; owned mutex was locked again
E_FAILUREmutex object can't be unlocked
E_STOPPEDcondition variable or mutex object was reseted
Note
use only in thread mode

◆ cnd_give()

void cnd_give ( cnd_t * cnd,
bool all )

signal one or all tasks that are waiting on the condition variable

Parameters
cndpointer to condition variable object
allsignal receiver
  • cndOne: notify one task that is waiting on the condition variable
  • cndAll: notify all tasks that are waiting on the condition variable

◆ cnd_notifyOne()

void cnd_notifyOne ( cnd_t * cnd)
inline

signal one task waiting on the condition variable

Parameters
cndpointer to condition variable object
Note
can be used in both thread and handler mode (for blockable interrupts)

◆ cnd_notifyAll()

void cnd_notifyAll ( cnd_t * cnd)
inline

signal all tasks waiting on the condition variable

Parameters
cndpointer to condition variable object
Note
can be used in both thread and handler mode (for blockable interrupts)