Hardware Reference
In-Depth Information
τ 4
stack 4
τ 3
stack 3
τ 2
stack 2
stack 1
τ 1
t 1
t 2
t 3
t 4
t 5
t 6
t 7
Figure 7.21
Possible evolution with one stack per task.
Note that the top of each process stack varies during the process execution, while
the storage region reserved for each stack remains constant and corresponds to the
distance between two horizontal lines. In this case, the total storage area that must be
reserved for the application is equal to the sum of the stack regions dedicated to each
process.
However, if all tasks are independent or use the SRP to access shared resources, then
they can share a single stack space. In this case, when a task τ is preempted by a task
τ , τ maintains its stack and the stack of τ is allocated immediately above that of τ .
Figure 7.22 shows a possible evolution of the previous task set when a single stack is
allocated to all tasks.
Under the SRP, stack overlapping without interpenetration is a direct consequence
of Theorem 7.5. In fact, since a task τ can never be blocked once started, its stack
can never be penetrated by the ones belonging to tasks with lower preemption levels,
which can resume only after τ is completed.
Note that the stack space between the two upper horizontal lines (which is equivalent
to the minimum stack between τ 2 and τ 3 ) is no longer needed, since τ 2 and τ 3 have
the same preemption level, so they can never occupy stack space at the same time.
In general, the higher the number of tasks with the same preemption level, the larger
stack saving.
For example, consider an application consisting of 100 tasks distributed on 10 pre-
emption levels, with 10 tasks for each level, and suppose that each task needs up to
10 Kbytes of stack space. Using a stack per task, 1000 Kbytes would be required. On
 
Search WWH ::




Custom Search