#include <rtl.h>
OS_RESULT os_mut_wait (
OS_IDmutex, /* The mutex to acquire */
U16 timeout ); /* Length of time to wait */
Description
The os_mut_wait function tries to acquire the mutex
identified by the function argument. If the mutex has not been locked
by another task, the calling task acquires and locks the mutex and
might continue immediately. If the mutex has been locked by another
task, then the RTX kernel puts the calling task to sleep until the
mutex becomes unlocked or until the timeout expires.
The timeout argument can have any value between 0 and
0xFFFE. Set timeout to 0xFFFF for an indefinite timeout
period. If a value of 0 has been specified, then the calling task
continues immediately even if there is a higher priority task in the
ready list.
This function also raises the priority of the owning task of the
mutex, if it is lower than the priority of the calling task. This
programming method is called priority inheritance and is used
to eliminate priority inversion problems. When a mutex is released,
the original priority of the owning task will be restored.
The os_mut_wait function is in the RL-RTX library. The
prototype is defined in rtl.h.
Note
Timeout is measured in number of system intervals.
You must initialize the mutex object using the
os_mut_init function before you can perform any operation on
it.
Return Value
The os_mut_wait function returns the completion value:
Return Value
Description
OS_R_MUT
The task waited until the mutex was released and has now
acquired and locked the mutex.
OS_R_TMO
The timeout has expired.
OS_R_OK
The mutex was available and the os_mut_wait function
returned to the calling task immediately.
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.