**6.6 RELTEQ tick handler with support for servers**

An example of the RELTEQ queues managed by the tick handler in the proposed RELTEQ extension with servers is summarized in Figure 9. Conceptually, every tick the stopwatch queue is incremented and the heads of the system queue, the active server queue and the active virtual server queue are decremented. If the head of any queue becomes 0, then their head event is popped and handled until the queue is exhausted or the head event has time larger than 0.

Actually, rather than decrementing the head of each active queue and checking whether it is 0, a *CurrentTime* counter is incremented and compared to the *Earliesttime*, which is set whenever the head of an active queue changes. If they are equal, then (i) the *CurrentTime* is subtracted from the heads of all the active queues, (ii) any head event with time 0 is popped and handled,

**6.7 Summary**

**7.1 Admission**

**7.2 Monitoring**

chapter.

**7. Hierarchical scheduling**

and (iii) the scheduler is called.

can be called by any task.

scheduler to select the highest priority ready task.

**7.3 Scheduling**

how our implementation of HSF addresses each of them.

out.

We have described a generic framework for supporting servers, which is tick based (Section 4.3) and limits the interference of inactive servers on system level (Section 6.2). The interference of inactive servers which are either ready or depleted was limited by means of a combination of inactive server queues and a stopwatch queue. Deactivating server queues of waiting servers was made possible by inserting a wakeup event into the system queue, in order to wake up the server upon the arrival of a periodic task while the server is switched

An Efficient Hierarchical Scheduling Framework for the Automotive Domain 85

Rajkumar et al. (1998) identified four ingredients necessary for guaranteeing resource provisions: admission, monitoring, scheduling and enforcement. In this section we describe

We allow admission of new components only during the integration, not during runtime. The admission testing requires analysis for hierarchical systems, which is outside the scope of this

There are two reasons for monitoring the budget consumption of servers: (i) handle the budget

In order to notice the moment when a server becomes depleted we have introduced a virtual *depletion event* for every server, which is inserted into its virtual server queue. When the depletion event expires, then (i) the server's capacity is set to 0, (ii) its state is set to depleted,

In order to allow tasks *τ<sup>j</sup>* ∈ *γ*(*σi*) to track the server budget *β<sup>i</sup>* we equipped each server with a *budget counter*. Upon every tick the budget counter of the currently active server is decremented by one. The depletion event will make sure that a depleted server is switched out before the counter becomes negative. We also added the *ServerBudget()* method, which

*ServerBudget(σi)* Returns the current value of *βi*, which represents the lower bound on the processor time that server *σ<sup>i</sup>* will receive within the next interval of Π*<sup>i</sup>* time units.

The *μ*C/OS-II the scheduler does two things: (i) select the highest priority ready task, and (ii) in case it is different from the currently running one, do a context switch. Our hierarchical scheduler replaces the original *OS\_SchedNew()* method, which is used by the *μ*C/OS-II

It first uses the *global scheduler HighestReadyServer()* to select the highest priority ready server, and then the server's *local scheduler HighestReadyTask()*, which selects the highest priority ready

depletion and (ii) allow the assigned tasks to track and adapt to the available budget.

(iii) *CurrentTime* is set to 0, and (iv) *Earliesttime* is set to the earliest time among the heads of all active queues3.

Fig. 9. Example of the RELTEQ queues managed by the tick handler.

The behavior of a RELTEQ tick handler supporting servers is summarized in Figure 10.

```
IncrementQueue(stopwatch);
CurrentTime := CurrentTime + 1;
if Earliesttime = CurrentTime then
  for all q ∈ activequeues do
     Head(q).time := Head(q).time − CurrentTime;
     while Head(q).time = 0 do
       HandleEvent(Head(q));
       PopEvent(q);
     end while
  end for
  CurrentTime := 0;
  Earliesttime := Earliest(activequeues);
  Schedule();
end if
```
Fig. 10. Pseudocode for the RELTEQ tick handler supporting hierarchical scheduling.

Note that at any moment in time there are at most four active queues, as shown in Figure 9.

<sup>3</sup> Note that the *time* of any event will never become negative.
