![]() |
m2mb API docs
25.30.003
m2mb API sets documentation
|
OS mutex prototypes. More...
Go to the source code of this file.
Macros | |
| #define | M2MB_OS_MTX_INVALID 0 |
| #define | M2MB_OS_MTX_INVALID_ATTR 0 |
| #define | m2mb_os_mtx_setAttrItem_(h, args...) m2mb_os_mtx_setAttrItem( h, CMDS_ARGS( args ) ) |
Typedefs | |
| typedef struct M2MB_OS_MTX_HANDLE_TAG * | M2MB_OS_MTX_HANDLE |
| typedef struct M2MB_OS_MTX_ATTR_HANDLE_TAG * | M2MB_OS_MTX_ATTR_HANDLE |
Functions | |
| M2MB_OS_RESULT_E | m2mb_os_mtx_init (M2MB_OS_MTX_HANDLE *pMtxHandle, M2MB_OS_MTX_ATTR_HANDLE *pMtxAttr) |
| Mutex Creation. More... | |
| M2MB_OS_RESULT_E | m2mb_os_mtx_deinit (M2MB_OS_MTX_HANDLE mtxHandle) |
| Mutex deinit or deletion. More... | |
| M2MB_OS_RESULT_E | m2mb_os_mtx_get (M2MB_OS_MTX_HANDLE mtxHandle, UINT32 timeoutTicks) |
| Get the ownership of the mutex (critical session enter) More... | |
| M2MB_OS_RESULT_E | m2mb_os_mtx_put (M2MB_OS_MTX_HANDLE mtxHandle) |
| Release ownership of the mutex (if counter = 0: exit critical section) More... | |
| M2MB_OS_RESULT_E | m2mb_os_mtx_hptf (M2MB_OS_MTX_HANDLE mtxHandle) |
| Prioritize mutex suspension list HPTF: Highest Priority Task First. More... | |
| M2MB_OS_RESULT_E | m2mb_os_mtx_setAttrItem (M2MB_OS_MTX_ATTR_HANDLE *pMtxAttrHandle, UINT8 nCmds,...) |
| Set specific attribute for mutex creation. More... | |
| M2MB_OS_RESULT_E | m2mb_os_mtx_getItem (M2MB_OS_MTX_HANDLE mtxHandle, M2MB_OS_MTX_SEL_CMD_E selCmd, MEM_W *pOut, void *pIn) |
| Get specific properties of the mutex. More... | |
| M2MB_OS_RESULT_E | m2mb_os_mtx_setItem (M2MB_OS_MTX_HANDLE mtxHandle, M2MB_OS_MTX_SEL_CMD_E selCmd, void *pIn) |
| Set specific properties of the mutex. More... | |
OS mutex prototypes.
m2m/m2m_generic/common/m2mb_inc/m2mb_os_mtxHandle.h
basic functions for OS mutex are provided
@notes Dependencies: m2mb_types.h m2mb_os_types.h
| M2MB_OS_RESULT_E m2mb_os_mtx_deinit | ( | M2MB_OS_MTX_HANDLE | mtxHandle | ) |
Mutex deinit or deletion.
This service deletes the specified os mutex. All tasks suspended waiting for this mutex are resumed with a
| [in] | pmTX | pointer handle of the mutex |
Example
| M2MB_OS_RESULT_E m2mb_os_mtx_get | ( | M2MB_OS_MTX_HANDLE | mtxHandle, |
| UINT32 | timeoutTicks | ||
| ) |
Get the ownership of the mutex (critical session enter)
This service attempts to obtain exclusive ownership of the specified mutex. If the calling task already owns the mutex, an internal counter is incremented and a successful status is returned. If the mutex is owned by another task and this task has higher priority and priority inheritance was specified at mutex create, the lower task'priority of the task owning the mutex will be temporarily raised to that of the calling task.
| [in] | mtxHandle | handle of mutex |
| [in] | timeoutTicks | If timeout is specified and mutex count is zero, task will be suspended for a maximum time of timeout ticks |
Example
| M2MB_OS_RESULT_E m2mb_os_mtx_getItem | ( | M2MB_OS_MTX_HANDLE | mtxHandle, |
| M2MB_OS_MTX_SEL_CMD_E | selCmd, | ||
| MEM_W * | pOut, | ||
| void * | pIn | ||
| ) |
Get specific properties of the mutex.
This service retrieve value for specified parameter of the specified mutex Selecting cmd, a parameter to be retrieved can be set To be used when mutex is already created: it is under application responsibility
| [in] | mtxHandle | handle of mutex |
| [in] | selCmd | Select parameter to be retrieved (see M2MB_OS_MTX_SEL_CMD_E) |
| [out] | pOut | pointer Output parameter got: its meaning depend on selCmd used See examples as general pointer it is set to MEM_W |
| [in] | pIn | pointer to void general Parameter to be specified, if any, to get right output See examples If parameter is not needed, use NULL |
Example
| M2MB_OS_RESULT_E m2mb_os_mtx_hptf | ( | M2MB_OS_MTX_HANDLE | mtxHandle | ) |
Prioritize mutex suspension list HPTF: Highest Priority Task First.
This service set the task waiting for this mutex which has currently highest priority, on the top of FIFO task suspension list It is one shot operation. To have highest priority task served first for every put, see m2m_os_mtx_setItem(..)
| [in] | mtxHandle | handle of mutex |
Example
| M2MB_OS_RESULT_E m2mb_os_mtx_init | ( | M2MB_OS_MTX_HANDLE * | pMtxHandle, |
| M2MB_OS_MTX_ATTR_HANDLE * | pMtxAttr | ||
| ) |
Mutex Creation.
This service creates a mutex for inter-task mutual exclusion for resource protection
| [out] | pMtxHandle | pointer to mutex handle |
| [in] | pMtxAttr | pointer to mutex attribute handle |
Example
| M2MB_OS_RESULT_E m2mb_os_mtx_put | ( | M2MB_OS_MTX_HANDLE | mtxHandle | ) |
Release ownership of the mutex (if counter = 0: exit critical section)
This service decrements the ownership count of the specified mutex. If the ownership count is zero, the mutex is made available.
| [in] | mtxHandle | handle of mutex |
Example
| M2MB_OS_RESULT_E m2mb_os_mtx_setAttrItem | ( | M2MB_OS_MTX_ATTR_HANDLE * | pMtxAttrHandle, |
| UINT8 | nCmds, | ||
| ... | |||
| ) |
Set specific attribute for mutex creation.
This service set the attribute (or create it) to be used for mutex creation
| [in] | selCmd | Select parameter to be set (see M2MB_OS_MTX_SEL_CMD_E) |
| [in] | pMtxAttr | pointer to mutex attribute of mutex |
| [in] | ... | variable inputs, N cmds (see M2MB_OS_MTX_SEL_CMD_E) followed by N arguments for their respective issued commands. CMDS(...) and CMDS_ARGS(...) macro can be used to better insert cmd and parameters and to better control right insertion |
Example
| M2MB_OS_RESULT_E m2mb_os_mtx_setItem | ( | M2MB_OS_MTX_HANDLE | mtxHandle, |
| M2MB_OS_MTX_SEL_CMD_E | selCmd, | ||
| void * | pIn | ||
| ) |
Set specific properties of the mutex.
This service set value for specified parameter of the specified mutex if available Selecting cmd, a parameter to be set can be selected To be used when mutex is already created: its right use is under application responsibility
| [in] | mtxHandle | handle of mutex |
| [in] | selCmd | Select parameter to be set (see M2MB_OS_MTX_SEL_CMD_E) |
| [in] | pIn | pointer to value to be set. If a simple value, can be easily casted to (void*) e.g. int value -3 has to be passed, use (void*)-3 NULL if no value is needed |
Example