
CHAPTER 13 SERVICE CALLS
User’s Manual U14833EJ2V0UM
222
Lock Mutex
loc_mtx
[Overview]
Locks a mutex
[C format]
#include <kernel.h>
ER loc_mtx(ID mtxid);
[Parameter]
I/O
Parameter
Description
I
ID
mtxiid
ID number of mutex to be locked
[Explanation]
The mutex specified by mtxid is locked.
If the target mutex can be locked, i.e., if locking the mutex is successful, the task continues processing. If the
mutex has the TA_CEILING attribute at this time and if the ceiling of the priority (ceilpri) specified when the mutex was
created is higher than the current priority of the task that locks the mutex, the priority of the task is raised to the ceiling
value.
If the mutex has been already locked by another task, the task enters the waiting state and is registered to the
waiting task queue in the order (on an FIFO basis or according to priority) specified when the mutex was created. If
the mutex has the TA_INHERIT attribute at this time and if the current priority of the task that has entered the waiting
state is higher than the current priority of the task that is locking the mutex, the priority of the locking task is lowered to
the current priority of the waiting task.
If the target mutex has the TA_CEILING attribute and if the base priority of the task is higher than the ceiling value
of the priority of the mutex, an error occurs and the error code E_ILUSE is returned.
The current priority raised by the mutex is changed to the base priority of the task when the task releases the lock
of the mutex (if the task locks two or more mutexes, when it releases the lock of all the mutexes).
Tasks placed in the waiting state due to loc_mtx are released from waiting by one of the following occurrences.
1.
unl_mtx is issued and the task locks a new mutex (E_OK).
2.
The locking task is terminated and a new mutex is locked (E_OK).
3.
(i)rel_wai is issued and the task is forcibly released from the waiting state (E_RLWAI).
4.
del_mtx is issued and the mutex is deleted (E_DLT).
[Differences from
μ
ITRON3.0]
loc_mtx is a newly created service call.