• No results found

Chapter 3 A Delay Composition Theorem for Real-Time Pipelines

3.4 Schedulability and Pipeline Reduction

In this section, we illustrate a systematic reduction of the pipeline schedulability problem to an equivalent single stage problem using the delay composition theorem. Since delay predicted by the delay composition theorem grows with set S, let us first define the worst-case (i.e., largest) set S, denoted Swc, of jobs that

delay or preempt J1. In this work, we suggest a very simple (and somewhat conservative) definition of set

Swc. We expect that future work can improve upon this definition using more in-depth analysis. In the

absence of further information, set Swc is defined as follows.

Definition: The worst-case set Swcof jobs that delay or preempt job J1 (hence, include execution intervals

where J1 was present in the pipeline, [A1, A1+ Delay(J1)].

Observe that the above is a conservative definition. It simply excludes the impossible. In a schedulable system, a job Ji that does not satisfy the above condition either completes prior to the the arrival of J1 or

arrives after its completion. Hence, it cannot possibly have execution intervals that delay or preempt J1.

Let ¯Swc ⊆ Swc denote the set of all jobs with higher priority than J1 and including J1, and let S

¯wc ⊂ Swc denote the set of all jobs with lower priority than J1. In Sections 3.4.1 and 3.4.2, we show how the reduction

of the pipeline to a single stage is carried out to analyze the schedulability of each task in the original system under preemptive and non-preemptive scheduling, respectively.

3.4.1

Reduction of Pipeline to an Equivalent Single Stage Under Preemptive

Scheduling

Let us divide the set ¯Swc into the subset ¯Sbef ⊆ ¯Swc that contains those jobs with Ai ≤ A1, and a subset

¯

Saf ter ⊂ ¯Swc that contains those jobs with Ai > A1. We can now rewrite the delay composition theorem,

separating its first summation into two; one for invocations that arrive before (or with) T1, and one for

those that arrive after. This allows us to substitute for Ceqi accordingly in each summation, resulting in the

following: Delay(J1) ≤ X Ji∈ ¯Sbef Ci,max1+ X Ji∈ ¯Saf ter (Ci,max1+ Ci,max2) + N −1 X j=1 max i (Ci,j) (3.13)

The reduction to a single stage system under preemptive scheduling is then conducted by (i) replacing each pipeline job Ji in ¯Sbef by an equivalent single stage job (with the same priority and deadline) of execution

time equal to Ci,max1, (ii) replacing each pipeline job Ji in ¯Saf ter by an equivalent single stage job of

execution time equal to Ci,max1+ Ci,max2, and (iii) adding a lowest-priority job, Je∗of execution time equal

to PN −1

j=1 maxi(Ci,j) (which is the last term in Inequality (3.13)), and deadline same as that of J1. By the

delay composition theorem, the total delay incurred by J1in the pipeline is no larger than the delay of Je∗on

the uniprocessor, since the latter adds up to the delay bound expressed on the right hand of Inequality (3.13). For example, let us illustrate this transformation in the case of rate-monotonic scheduling of periodic tasks with periods equal to end-to-end deadlines. Consider a set of periodic tasks arriving at a pipeline, where each task Ti has a period Pi. As shown in Figure 3.7, there can be at most one invocation of each

higher-priority task Ti in set ¯Sbef. Similarly, the number of invocations of each task Ti that arrive after the

invocation of T1(say J1) and delay it, is no larger than ⌈Delay(JPi 1)⌉. Following the reduction outlined above,

then aggregating jobs of the same period into single periodic tasks, the following periodic task set is reached: • Task T∗

C∗ e =

P

Ji∈ ¯SbefCi,max1+

PN −1

j=1 maxi(Ci,j). The task further has the same period and deadline as T1

in the original set.

• Tasks Ti∗, each has the same period and deadline as one Ti in the original set, and has an execution

time equal to C∗ i = Ci,max1+ Ci,max2. Arrivals of task Ti Arrival of task T1 Not a member of S_{wc} as its interval does not overlap with that of T1

One invocation of Ti that arrives prior to T1 is

part of S_{wc}

Delay(T1)/Pi invocations of Ti that arrive after T1 are

part of S_{wc}

time

Figure 3.7: Invocations in Swc.

Hence, if task Te∗ is schedulable on a uniprocessor, so is J1 on the original pipeline. The transformation

is complete. In Section 3.6, we present pipeline schedulability expressions for deadline monotonic scheduling based on the above task set reduction.

Likewise, the transformation to analyze the schedulability of T1 in the pipeline, for the same task set

under EDF scheduling, results in the following single stage task set (the set Sbef includes all invocations of

tasks that have an earlier arrival time to the system and higher priority than the invocation of T1 under

consideration): • Task T∗

e with a computation time Ce∗=

P

Ji∈SbefCi,max1

+PN −1

j=1 maxi(Ci,j). Note that under EDF one invocation of every other task can have an earlier

arrival time and end-to-end deadline (and higher priority) than that of the invocation of T1(and hence

be part of Sbef). This is in contrast to RM scheduling, where all invocations of a task have the same

priority, and only invocations of higher priority tasks were part of Sbef. Te∗further has the same period

and deadline as T1 in the original set.

• For each Tithat has a smaller relative deadline than T1in the original task set, there is a corresponding

task T∗

i, having the same period and deadline as Tiand execution time equal to Ci∗= Ci,max1+Ci,max2.

This is due to the fact that only tasks with a smaller relative deadline than T1 can arrive after the

invocation of T1 and have an earlier absolute deadline.

In Section 3.5, we provide a numeric example to illustrate the transformation and schedulability analysis of a periodic task set under EDF scheduling.

3.4.2

Reduction of Pipeline to an Equivalent Single Stage Under

Non-Preemptive Scheduling

In this section, we show how the schedulability analysis of a job in a pipeline scheduled using non-preemptive scheduling can be reduced to that in an equivalent single stage system under preemptive scheduling. This is performed by (i) replacing each job Ji in ¯Swc by an equivalent single stage job of execution time

equal to Ci,max, and (ii) adding a lowest-priority job, Je∗ of execution time

P

j≤N −1maxJi∈ ¯Swc(Ci,j) +

P

j≤NmaxJi∈S

¯wc(Ci,j) (which are the last two terms in Inequality (3.2)), and deadline same as that of J1.

The delay due to blocking of resources by lower priority jobs is included as part of the execution time of Je∗. Further, note that in the above transformation, the constructed single stage system is scheduled using

preemptive scheduling, while the original pipeline system was scheduled using non-preemptive scheduling. This is due to the fact that higher priority jobs can overtake J1 in the pipeline, which corresponds to the

equivalent higher priority jobs preempting J1in the single stage system. It follows from the non-preemptive

delay composition theorem, that the end-to-end delay experienced by J1 in the pipelined system under

non-preemptive scheduling, is no larger than the delay experienced by J∗

e in the uniprocessor system under

preemptive scheduling. Thus, if J∗

e is schedulable on the uniprocessor, so is J1 on the original pipelined system. The reduction

for periodic tasks can be conducted similar to the description under preemptive scheduling. In Section 3.6, we show how well known uniprocessor schedulability analysis can be applied to the analysis of pipelines scheduled under non-preemptive scheduling.

3.5

A Numeric Example

To illustrate the application of the above approach, consider a three stage pipeline traversed by four tasks whose per-stage computation times, end-to-end deadlines, and periods are given in Table 3.1. Let the pipeline be scheduled in an EDF manner. We assume a simple uniprocessor schedulability test that checks if the sum of the ratios of computation times to deadlines of tasks is at most 1. This test is only a sufficient test when deadlines can be lesser than the periods of tasks. In this section, we demonstrate how this task set is transformed into single-stage schedulability problems and solved to determine if the pipeline is schedulable.

Task Ci,1 Ci,2 Ci,3 Deadline Period

T1 1 0.5 0.5 8 8

T2 0.5 1 1 10 12

T3 0.5 0.5 1 10 15

T4 1 1 0.5 12 15

As there are four tasks in the system, four single stage systems need to be analyzed. While considering the schedulability of task Ti, a task Te∗(Ti) is created in the corresponding hypothetical single stage system.

As the scheduling policy is EDF, T∗

e(Ti)’s execution time is one maximum stage execution time of every task

(one invocation of every other task could be present in the system when Tiarrives) added to the maximum

stage execution times on the first two stages, for all i. Therefore, C∗

e(Ti) = 4 + 2 = 6 time units, for all

i. The deadline of T∗

e(Ti) is the same as that of Ti. The other tasks that would be created in the four

single stage systems are T∗

1, T2∗, T3∗, and T4∗. The execution time of task Ti∗ is the sum of the two largest

stage execution times of task Ti, and the deadline of Ti∗is same as the deadline of Ti. Therefore, C1∗= 1.5,

C∗

2 = 2, C3∗= 1.5, and C4∗= 2.

Task T1: The corresponding single stage system will contain only the task Te∗(T1) (as invocations of other

tasks that arrive after T∗

e(T1) would not execute ahead of it under EDF). By applying the uniprocessor test,

as 68 < 1, T1 is schedulable.

Task T2: The single stage system consists of two tasks Te∗(T2) and T1∗. As 1.58 + 6

10 = 0.7875 < 1, T2 is

schedulable.

Task T3: The single stage system consists of three tasks Te∗(T3), T1∗, and T2∗. As 1.58 + 2 10+

6

10 = 0.9875 < 1,

T3is schedulable.

Task T4: The single stage system consists of four tasks Te∗(T4), T1∗, T2∗, and T3∗. 1.58 + 2 10 + 2 10+ 6 12 =

1.0875 > 1. Therefore, T4 may not be schedulable.

However, T4’s schedulability can be analyzed by changing the schedulability test used. For example, by

calculating the actual number of invocations of T∗

1, T2∗, and T3∗that arrive after the invocation of Te∗(T4) and

preempt it, T4’s schedulability can be precisely determined. Under EDF, only one invocation each of T1∗, T2∗,

and T∗

3 would arrive after Te∗(T4), and have a deadline earlier than Te∗(T4). Therefore, the total worst case

delay to the invocation of T∗

e(T4) (and hence of T4), is Ce∗(T4) + C1∗+ C2∗+ C3∗= 6 + 1.5 + 2 + 1.5 = 11 < 12.

Therefore, T4is schedulable.

The delay composition theorem and the reduction can thus be used for a variety of scheduling policies and schedulability tests.