OSMutexDel()
void OSMutexDel (OS_MUTEX *p_mutex,
OS_OPT opt,
OS_ERR *p_err)
File |
Called from |
Code enabled by |
os_mutex.c |
Task only |
OS_CFG_MUTEX_EN and OS_CFG_MUTEX_DEL_EN |
OSMutexDel() is used to delete a mutex. This function should be used with care because multiple tasks may rely on the presence of the mutex. Generally speaking, before deleting a mutex, first delete all the tasks that access the mutex. However, as a general rule, do not delete kernel objects at run-time.
Arguments
p_mutex
is a pointer to the mutex to delete.
opt
specifies whether to delete the mutex only if there are no pending tasks (OS_OPT_DEL_NO_PEND), or whether to always delete the mutex regardless of whether tasks are pending or not (OS_OPT_DEL_ALWAYS). In this case, all pending tasks are readied.
p_err
is a pointer to a variable that is used to hold an error code:
Returned Value
The number of tasks that were waiting for the mutex and 0 if an error occurred.
Notes/Warnings
Use this call with care as other tasks may expect the presence of the mutex.
Example
OS_MUTEX DispMutex;
void Task (void *p_arg) { OS_ERR err;
(void)&p_arg; while (DEF_ON) { : : OSMutexDel(&DispMutex, OS_OPT_DEL_ALWAYS, &err); /* Check “err” */ : : } } |