IntrOS
Loading...
Searching...
No Matches
Mutex

mutexes (error check) More...

Macros

#define OS_MTX(mtx)
 define and initialize a mutex object
#define static_MTX(mtx)
 static alias of OS_MTX()
#define MTX_INIT()
 create and initialize a mutex object
#define MTX_CREATE()
 create and initialize a mutex object
#define MTX_NEW   MTX_CREATE
 alias of MTX_CREATE()

Functions

void mtx_init (mtx_t *mtx)
 initialize a mutex object
void mtx_reset (mtx_t *mtx)
 reset the mutex object and wake up all waiting tasks with 'E_STOPPED' event value
void mtx_kill (mtx_t *mtx)
 alias of mtx_reset()
int mtx_take (mtx_t *mtx)
 try to lock the mutex object, don't wait if the mutex object can't be locked immediately
int mtx_tryLock (mtx_t *mtx)
 alias of mtx_take()
int mtx_waitFor (mtx_t *mtx, cnt_t delay)
 try to lock the mutex object, wait for given duration of time if the mutex object can't be locked immediately
int mtx_waitUntil (mtx_t *mtx, cnt_t time)
 try to lock the mutex object, wait until given timepoint if the mutex object can't be locked immediately
int mtx_wait (mtx_t *mtx)
 try to lock the mutex object, wait indefinitely if the mutex object can't be locked immediately
int mtx_lock (mtx_t *mtx)
 alias of mtx_wait()
int mtx_give (mtx_t *mtx)
 try to unlock the mutex object (only owner task can unlock mutex object), don't wait if the mutex object can't be unlocked
int mtx_unlock (mtx_t *mtx)
 alias of mtx_give()

Detailed Description

mutexes (error check)

Macro Definition Documentation

◆ OS_MTX

#define OS_MTX ( mtx)
Value:
mtx_t mtx[] = { _MTX_INIT() }

define and initialize a mutex object

Parameters
mtxname of a pointer to mutex object

◆ static_MTX

#define static_MTX ( mtx)
Value:
static mtx_t mtx[] = { _MTX_INIT() }

static alias of OS_MTX()

◆ MTX_INIT

#define MTX_INIT ( )
Value:
_MTX_INIT()

create and initialize a mutex object

Returns
mutex object
Note
use only in 'C' code

◆ MTX_CREATE

#define MTX_CREATE ( )
Value:
{ MTX_INIT () }
#define MTX_INIT()
create and initialize a mutex object
Definition osmutex.h:95

create and initialize a mutex object

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

Function Documentation

◆ mtx_init()

void mtx_init ( mtx_t * mtx)

initialize a mutex object

Parameters
mtxpointer to mutex object

◆ mtx_reset()

void mtx_reset ( mtx_t * mtx)

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

Parameters
mtxpointer to mutex object
Note
use only in thread mode

◆ mtx_take()

int mtx_take ( mtx_t * mtx)

try to lock the mutex object, don't wait if the mutex object can't be locked immediately

Parameters
mtxpointer to mutex object
Return values
E_SUCCESSmutex object was successfully locked
E_FAILUREmutex object can't be locked
E_TIMEOUTmutex object can't be locked immediately, try again

◆ mtx_waitFor()

int mtx_waitFor ( mtx_t * mtx,
cnt_t delay )

try to lock the mutex object, wait for given duration of time if the mutex object can't be locked immediately

Parameters
mtxpointer to mutex object
delayduration of time (maximum number of ticks to wait for lock the mutex object)
  • IMMEDIATE: don't wait if the mutex object can't be locked immediately
  • INFINITE: wait indefinitely until the mutex object has been locked
Return values
E_SUCCESSmutex object was successfully locked
E_FAILUREmutex object can't be locked
E_STOPPEDmutex object was reseted before the specified timeout expired
E_TIMEOUTmutex object was not locked before the specified timeout expired

◆ mtx_waitUntil()

int mtx_waitUntil ( mtx_t * mtx,
cnt_t time )

try to lock the mutex object, wait until given timepoint if the mutex object can't be locked immediately

Parameters
mtxpointer to mutex object
timetimepoint value
Return values
E_SUCCESSmutex object was successfully locked
E_FAILUREmutex object can't be locked
E_STOPPEDmutex object was reseted before the specified timeout expired
E_TIMEOUTmutex object was not locked before the specified timeout expired

◆ mtx_wait()

int mtx_wait ( mtx_t * mtx)
inline

try to lock the mutex object, wait indefinitely if the mutex object can't be locked immediately

Parameters
mtxpointer to mutex object
Return values
E_SUCCESSmutex object was successfully locked
E_FAILUREmutex object can't be locked
E_STOPPEDmutex object was reseted

◆ mtx_give()

int mtx_give ( mtx_t * mtx)

try to unlock the mutex object (only owner task can unlock mutex object), don't wait if the mutex object can't be unlocked

Parameters
mtxpointer to mutex object
Return values
E_SUCCESSmutex object was successfully unlocked
E_FAILUREmutex object can't be unlocked