|
StateOS
|
mutexes with configurable type, protocol and robustness More...
Macros | |
| #define | mtxNormal 0U |
| normal mutex | |
| #define | mtxErrorCheck 1U |
| error checking mutex | |
| #define | mtxRecursive 2U |
| recursive mutex | |
| #define | mtxDefault mtxNormal |
| default mutex type | |
| #define | mtxPrioNone 0U |
| none | |
| #define | mtxPrioInherit 4U |
| priority inheritance mutex | |
| #define | mtxPrioProtect 8U |
| priority protected mutex (ICPP, POSIX PTHREAD_PRIO_PROTECT): the owner runs at least | |
| #define | mtxStalled 0U |
| stalled mutex | |
| #define | mtxRobust 16U |
| robust mutex | |
| #define | mtxInconsistent 32U |
| inconsistent mutex | |
| #define | OS_MTX(mtx, mode, ...) |
| define and initialize a mutex object | |
| #define | static_MTX(mtx, mode, ...) |
| static alias of OS_MTX() | |
| #define | MTX_INIT(mode, ...) |
| create and initialize a mutex object | |
| #define | MTX_CREATE(mode, ...) |
| create and initialize a mutex object | |
| #define | MTX_NEW MTX_CREATE |
| alias of MTX_CREATE() | |
Functions | |
| void | mtx_init (mtx_t *mtx, unsigned mode, unsigned prio) |
| initialize a mutex object | |
| mtx_t * | mtx_create (unsigned mode, unsigned prio) |
| create and initialize a new mutex object | |
| mtx_t * | mtx_new (unsigned mode, unsigned prio) |
| alias of mtx_create() | |
| 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() | |
| void | mtx_destroy (mtx_t *mtx) |
| reset the mutex object, wake up all waiting tasks with 'E_DELETED' event value and free allocated resource | |
| void | mtx_delete (mtx_t *mtx) |
| alias of mtx_destroy() | |
| unsigned | mtx_prio (mtx_t *mtx) |
| get priority of given mutex | |
| 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() | |
mutexes with configurable type, protocol and robustness
| #define OS_MTX | ( | mtx, | |
| mode, | |||
| ... ) |
define and initialize a mutex object
| mtx | name of a pointer to mutex object |
| mode | mutex mode (mutex type + mutex protocol + mutex robustness)
|
| ... | prio: mutex priority ceiling; used only with mtxPrioProtect protocol |
| #define static_MTX | ( | mtx, | |
| mode, | |||
| ... ) |
static alias of OS_MTX()
| #define MTX_INIT | ( | mode, | |
| ... ) |
create and initialize a mutex object
| mode | mutex mode (mutex type + mutex protocol + mutex robustness)
|
| ... | prio: mutex priority ceiling; used only with mtxPrioProtect protocol |
| #define MTX_CREATE | ( | mode, | |
| ... ) |
create and initialize a mutex object
| mode | mutex mode (mutex type + mutex protocol + mutex robustness)
|
| ... | prio: mutex priority ceiling; used only with mtxPrioProtect protocol |
| void mtx_init | ( | mtx_t * | mtx, |
| unsigned | mode, | ||
| unsigned | prio ) |
initialize a mutex object
| mtx | pointer to mutex object |
| mode | mutex mode (mutex type + mutex protocol + mutex robustness)
|
| prio | mutex priority ceiling; used only with mtxPrioProtect protocol |
| mtx_t * mtx_create | ( | unsigned | mode, |
| unsigned | prio ) |
create and initialize a new mutex object
| mode | mutex mode (mutex type + mutex protocol + mutex robustness)
|
| prio | mutex priority ceiling; used only with mtxPrioProtect protocol |
| NULL | object not created (not enough free memory) |
| void mtx_reset | ( | mtx_t * | mtx | ) |
reset the mutex object and wake up all waiting tasks with 'E_STOPPED' event value
| mtx | pointer to mutex object |
| void mtx_destroy | ( | mtx_t * | mtx | ) |
reset the mutex object, wake up all waiting tasks with 'E_DELETED' event value and free allocated resource
| mtx | pointer to mutex object |
| unsigned mtx_prio | ( | mtx_t * | mtx | ) |
get priority of given mutex
| mtx | pointer to mutex object |
| int mtx_take | ( | mtx_t * | mtx | ) |
try to lock the mutex object, don't wait if the mutex object can't be locked immediately
| mtx | pointer to mutex object |
| E_SUCCESS | mutex object was successfully locked |
| OWNERDEAD | mutex object was successfully locked, previous owner has stopped |
| E_FAILURE | mutex object can't be locked (also: the task priority is above the priority ceiling of a mtxPrioProtect mutex) |
| E_TIMEOUT | mutex object can't be locked immediately, try again |
| 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
| mtx | pointer to mutex object |
| delay | duration of time (maximum number of ticks to wait for lock the mutex object)
|
| E_SUCCESS | mutex object was successfully locked |
| OWNERDEAD | mutex object was successfully locked, previous owner has stopped |
| E_FAILURE | mutex object can't be locked (also: the task priority is above the priority ceiling of a mtxPrioProtect mutex) |
| E_STOPPED | mutex object was reseted before the specified timeout expired |
| E_DELETED | mutex object was deleted before the specified timeout expired |
| E_TIMEOUT | mutex object was not locked before the specified timeout expired |
| 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
| mtx | pointer to mutex object |
| time | timepoint value |
| E_SUCCESS | mutex object was successfully locked |
| OWNERDEAD | mutex object was successfully locked, previous owner has stopped |
| E_FAILURE | mutex object can't be locked (also: the task priority is above the priority ceiling of a mtxPrioProtect mutex) |
| E_STOPPED | mutex object was reseted before the specified timeout expired |
| E_DELETED | mutex object was deleted before the specified timeout expired |
| E_TIMEOUT | mutex object was not locked before the specified timeout expired |
|
inline |
try to lock the mutex object, wait indefinitely if the mutex object can't be locked immediately
| mtx | pointer to mutex object |
| E_SUCCESS | mutex object was successfully locked |
| OWNERDEAD | mutex object was successfully locked, previous owner has stopped |
| E_FAILURE | mutex object can't be locked (also: the task priority is above the priority ceiling of a mtxPrioProtect mutex) |
| E_STOPPED | mutex object was reseted |
| E_DELETED | mutex object was deleted |
| int mtx_give | ( | mtx_t * | mtx | ) |