Hardware Reference
In-Depth Information
Although the preemption test for a task τ is performed before τ starts executing,
resources are not allocated at this time but only when requested.
A task can be blocked by the preemption test even though it does not require any
resource. This is needed to avoid unbounded priority inversion.
Blocking at preemption time, rather than at access time, introduces more pes-
simism and could create unnecessary blocking (as under HLP), but it decreases
the number of context switches, reduces the run-time overhead, and simplifies
the implementation of the protocol.
The preemption test has the effect of imposing priority inheritance; that is, an ex-
ecuting task that holds a resource modifies the system ceiling and resists preemp-
tion as though it inherits the priority of any tasks that might need that resource.
Note that this effect is accomplished without modifying the priority of the task.
EXAMPLE
In order to illustrate how the SRP works, consider the task set already described in
Table 7.3. The structure of the tasks is shown in Figure 7.18, where wait ( R k ,r )
denotes the request of r units of resource R k , and signal ( R k ) denotes their release.
The current ceilings of the resources have already been shown in Table 7.4, and a
possible EDF schedule for this task set is depicted in Figure 7.19. In this figure, the
fourth timeline reports the variation of the system ceiling, whereas the numbers along
the schedule denote resource indexes.
At time t 0 , τ 3 starts executing and the system ceiling is zero because all resources are
completely available. When τ 3 enters its first critical section, it takes the only unit of
R 2 ; thus, the system ceiling is set to the highest preemption level among the tasks that
could be blocked on R 2 (see Table 7.4); that is, Π s = π 2 =2. As a consequence,
τ 2 is blocked by the preemption test and τ 3 continues to execute. Note that when τ 3
enters its nested critical section (taking all units of R 1 ), the system ceiling is raised to
Π s = π 1 =3. This causes τ 1 to be blocked by the preemption test.
As τ 3 releases R 1 (at time t 2 ), the system ceiling becomes Π s =2; thus, τ 1 preempts
τ 3 and starts executing. Note that once τ 1 is started, it is never blocked during its
execution, because the condition π 1 > Π s guarantees that all the resources needed by
τ 1 are available. As τ 1 terminates, τ 3 resumes the execution and releases resource R 2 .
As R 2 is released, the system ceiling returns to zero and τ 2 can preempt τ 3 . Again,
once τ 2 is started, all the resources it needs are available; thus, τ 2 is never blocked.
Search WWH ::




Custom Search