The os_mut_release function decrements the internal counter of the mutex identified by the function argument in order to release the mutex. Only when the internal counter of the mutex is zero, then the mutex is really free to be acquired by another task. The mutex object knows the task that currently owns it. Hence the owning task can acquire and lock the mutex as many times as needed using the os_mut_wait function. When a task that owns a mutex tries to acquire it again, the task does not get blocked, but the mutex's internal counter is incremented. The task that acquired the mutex must release the mutex as many times as it was acquired, so that the internal counter of the mutex is decremented to 0. This function also restores the original task's priority if priority inheritance has been applied to the owning task of the mutex and his priority has been temporary raised. The os_mut_release function is in the RL-RTX library. The prototype is defined in rtl.h. Note - Initialize the mutex object with os_mut_init before performing any operation on it.
|