
CHAPTER 5 SYNCHRONOUS COMMUNICATION MANAGEMENT
User’s Manual U14833EJ2V0UM
66
5.6.5
Simplified priority order control rules
In the
μ
ITRON4.0 Specification, two kinds of priority control rules related to mutexes are prescribed: detailed rules
and simplified rules, of which the latter are used in the RX4000.
The priority order of tasks that use mutexes to perform synchronization is therefore as follows.
(When mutex is locked)
Whichever has the highest priority among the following.
The task’s base priority value
The same priority value as the task with the highest priority among tasks waiting to lock a locked mutex with
the attribute TA_INHERIT
The highest top priority among locked mutexes with the attribute TA_CEILING.
(After mutex lock is released)
When all the locked mutexes are released, a task’s current priority changes to its base priority.
5.6.6
Locking mutexes
A mutex is locked by issuing one of the service calls loc_mtx, tloc_mtx, or ploc_mtx.
If there is a mutex lock request, the kernel checks whether that mutex is already locked by another task. If the
mutex is not locked by another task, the mutex can be locked by the requesting task. At this time, if the target mutex
has the attribute TA_CEILING, the current priority value of the task is raised to the top priority value of the mutexes. If
the mutex is locked by another task, the requesting task is put in the waiting state and registered in the waiting task
queue of the mutex. The order in which tasks are registered in this queue is FIFO order if the target mutex has the
attribute TA_TFIFO, and priority order if the mutex has one of the other attributes TA_TPRI, TA_INHERIT, or
TA_CEILING. Also, if the mutex has the attribute TA_INHERIT and the current priority of the waiting task is higher
than that of the task locking the mutex, the latter task’s priority is changed.
Note that when tloc_mtx is issued, the is released from waiting if the mutex cannot be locked within a specified
time. Note also that a mutex cannot be locked by processing units other than tasks.
5.6.7
Releasing mutex locks
A mutex lock is released by issuing the service call unl_mtx.
If a mutex lock is released when there are tasks waiting, the task at the top of the waiting task queue locks that
mutex. At this time, if the mutex has the attribute TA_CEILING, the priority value of the task newly locking the mutex is
changed to the top priority value of the mutexes. If the mutex has the attribute TA_INHERIT, because the task queue
has already been sorted into priority order, the priority of the task newly locking the mutex remains unchanged.
Note that if all mutexes being locked by a task are released, the task’s priority changes to its base priority.
5.6.8
Obtaining mutex information
Mutex information such as the ID number of a locked task can be obtained by using the service calls ref_mtx and
iref_mtx. For details of each service call, refer to
CHAPTER 13
.