Hardware Reference
In-Depth Information
stack 3
stack 4
stack 2
τ 4
τ 3
τ 2
stack 1
τ 1
t 1
t 2
t 3
t 4
t 5
t 7
Figure 7.22
Possible evolution with a single stack for all tasks.
the contrary, using a single stack, only 100 Kbytes would be sufficient, since no more
than one task per preemption level could be active at one time. Hence, in this example
we would save 900 Kbytes; that is, 90%. In general, when tasks are distributed on
k preemption levels, the space required for a single stack is equal to the sum of the
largest request on each level.
7.8.6
IMPLEMENTATION CONSIDERATIONS
The implementation of the SRP is similar to that of the PCP, but the locking opera-
tions ( srp wait and srp signal ) are simpler, since a task can never be blocked when
attempting to lock a semaphore. When there are no sufficient resources available to
satisfy the maximum requirement of a task, the task is not permitted to preempt and is
kept in the ready queue.
To simplify the preemption test, all the ceilings of the resources (for any number of
available units) can be precomputed and stored in a table. Moreover, a stack can be
used to keep track of the system ceiling. When a resource R is allocated, its current
state, n R , is updated and if C R ( n R ) > Π s , then Π s is set to C R ( n R ). The old values
of n R and Π s are pushed onto the stack. When resource R is released, the values of
Π s and n R are restored from the stack. If the restored system ceiling is lower than
the previous value, the preemption test is executed on the ready task with the highest
priority to check whether it can preempt. If the preemption test is passed, a context
switch is performed; otherwise, the current task continues its execution.
 
Search WWH ::




Custom Search