Hardware Reference
In-Depth Information
B 3 =5
B 3 =5+4+3=12 == >B 3 =5
B 4 = B 4 =0 == >B 4 =0
To understand why the algorithm is pessimistic, note that B 2 is computed by adding
the duration of two critical sections both guarded by semaphore S 1 , which can never
occur in practice.
7.6.4
IMPLEMENTATION CONSIDERATIONS
The implementation of the Priority Inheritance Protocol requires a slight modification
of the kernel data structures associated with tasks and semaphores. First of all, each
task must have a nominal priority and an active priority, which need to be stored in
the Task Control Block (TCB). Moreover, in order to speed up the inheritance mech-
anism, it is convenient that each semaphore keeps track of the task holding the lock
on it. This can be done by adding in the semaphore data structure a specific field, say
holder , for storing the identifier of the holder. In this way, a task that is blocked on
a semaphore can immediately identify the task that holds its lock for transmitting its
priority. Similarly, transitive inheritance can be simplified if each task keeps track of
the semaphore on which it is blocked. In this case, this information has to be stored in
a field, say lock , of the Task Control Block. Assuming that the kernel data structures
are extended as described above, the primitives pi wait and pi signal for realizing the
Priority Inheritance Protocol can be defined as follows.
pi wait(s)
If semaphore s is free, it becomes locked and the name of the executing task is
stored in the holder field of the semaphore data structure.
If semaphore s is locked, the executing task is blocked on the s semaphore queue,
the semaphore identifier is stored in the lock field of the TCB, and its priority is
inherited by the task that holds s . If such a task is blocked on another semaphore,
the transitivity rule is applied. Then, the ready task with the highest priority is
assigned to the processor.
pi signal(s)
If the queue of semaphore s is empty (that is, no tasks are blocked on s ), s is
unlocked.
Search WWH ::




Custom Search