• No results found

Table 4.1:ComputingD and⃗ S for the CSDF graph shown in Figure 2.1 on page 29 under different⃗ values of⃗η. ⃗ η D⃗ S⃗ ⃗1 (︀8, 12, 24, 8⌋︀T (︀0, 8, 24, 32⌋︀T ⃗ 0.5 (︀6, 10, 24, 6⌋︀T (︀0, 6, 22, 30⌋︀T ⃗ 0 (︀5, 8, 24, 4⌋︀T (︀0, 5, 21, 29⌋︀T

Now, we can merge (4.30) and (4.31) which results in:

∀k=0, 1,⋯,α∶ prdS

(︀Si,max{Si,t′}+k)

(Ai,Eu) ≥ cnsS

(︀t′,max{Si,t}+k⌋︀(Aj,Eu) (4.32)

Any value oft′which satisfies (4.32) is a valid start time value that guarantees periodic execution ofAj. Since there might be multiple values oft′that satisfy (4.32), we take the minimum one because it is the earliest start time that guarantees periodic

execution ofAj. ∎

Example4.4.1. Now, we give an example on how to compute the earliest start times and deadlines for a given CSDF graph. Consider the CSDF graph shown in Figure 2.1 on page 29. Recall from Example 4.3.1 on page 56 thatC⃗= (︀5, 8, 24, 4⌋︀TandP⃗ˇ= (︀8, 12, 24, 8⌋︀T.

In Table 4.1, we show the values of start times and deadlines under different values of the deadline factorsη⃗. These values are computed by applying Lemma 4.4.2 and (4.22)

to the graph. ◻

4.5

Deriving Buffer Sizes

The third step in the scheduling framework is to derive a bounded buffer size of each communication channel in the graph. Similar to the start time, we prove in Theorem 4.3.1 the existence of a periodic schedule when each channel has a bounded buffer size. However, the buffer size used in Theorem 4.3.1 issufficientbut notminimum. Therefore, we would like to derive the minimum buffer sizes that guarantee periodic execution of all the actors.

Definition 4.5.1(Valid Buffer Size). LetEu= (Ai,Aj)be a communication channel

in a graphG. Under a periodic schedule, avalid buffer sizeofEu, denoted bybu, guarantees thatAi can store tokens toEuat time instantsSi+kPifor allk∈N0.

Definition 4.5.1 implies that a producer never blocks when writing to a commu- nication channel which has a valid buffer size (i.e., no buffer overflow). Similar to

62 Chapter 4. Scheduling Framework

Lemma 4.4.1, we want to derive the conditions under which one can compute the mini- mum buffer size such that it is always valid regardless of when the actors are actually scheduled to write/read during their periods.

Lemma 4.5.1. Let Eu = (Ai,Aj)be a communication channel in a graph G. Suppose that Euhas a valid buffer size that is derived when Ai is always scheduled to write as early as possible and Ajis always scheduled to read as late as possible. buremains valid when Ai is scheduled to write later and/or Ajis scheduled to read earlier.

Proof. IfAi is scheduled to write later, then this leads to the tokens being written later on the channel. Thus,Ai can never have a blocking write regardless of when Ajis scheduled to read becausebuis valid and is derived assuming thatAjis always

scheduled to read as late as possible. IfAjis scheduled to read earlier, then this leads to shorter stay of the tokens in the channel. Thus,Aican never block on writing since buis valid and the channel has enough free space. ∎

Lemma 4.5.1 states that the buffer size derived when the tokens production happens as early as possible and the tokens consumption happens as late as possible is valid regardless of when the actors are actually scheduled to execute during their periods. Thus, for the purpose of computing the buffer size, the cumulative production function assumes that the tokens production happens as early as possible. In this case, the cumulative production function is denoted by prdB(︀ts,te⌋︀(Ai,Eu)and is given by:

prdB (︀ts,te⌋︀ (Ai,Eu) = )︀ ⌉︀ ⌉︀ ⌋︀ ⌉︀ ⌉︀ ]︀ Xu i([︂te−ts Pi ⌉︂ +1) if(te−ts)modPi =0 Xu i([︂te−ts Pi ⌉︂) if(te−ts)modPi ≠0 (4.33) Similarly, for the purpose of computing the buffer size, the cumulative consumption function assumes that the data consumption happens as late as possible. In this case, the function is denoted by cnsB(︀ts,te)(Ai,Eu)and is given by

cnsB (︀ts,te) (Ai,Eu) = )︀ ⌉︀ ⌉︀ ⌋︀ ⌉︀ ⌉︀ ]︀ Yu i (⟨︀te−ts Pi ⧹︀ +1) if(te−ts)modPi ≥Di Yu i (⟨︀te−ts Pi ⧹︀) if(te−ts)modPi <Di (4.34) Lemma 4.5.2. For a graph G, the minimum bounded buffer size buof a communication channel Eu= (Ai,Aj)under a periodic schedule is given by

bu = max k∈(︀0,1,⋯,α⌋︀ )︀ ⌉︀ ⌉︀ ⌋︀ ⌉︀ ⌉︀ ]︀ prdB (︀Si,max{Si,Sj}+k⌋︀ (Ai,Eu) − cnsB (︀Sj,max{Si,Sj}+k) (Aj,Eu) [︀ ⌉︀ ⌉︀ ⌈︀ ⌉︀ ⌉︀ ⌊︀ (4.35) Proof. (4.35) tracks the maximum cumulative number of unconsumed tokens inEu during one iteration forAiandAj. There are two cases:

4.5. Deriving Buffer Sizes 63

Ai

Aj

Si Sj Si+α Sj+α

t1 t2 t3

Figure 4.11:Execution time-lines of Aiand Ajwhen Si≤Sj

Ai Aj

Si

Sj Sj+α Si+α

t1 t2 t3

Figure 4.12:Execution time-lines of Aiand Ajwhen Si>Sj

Case I: Si ≤Sj In this case, (4.35) tracks the maximum cumulative number of

unconsumed tokens inEuduring the time interval(︀Si,Sj+α). Figure 4.11 illustrates

the execution time-lines ofAi andAj when Si ≤ Sj. In intervalt1, Ai is actively

producing tokens whileAjhas not yet started executing. As a result, it is necessary to buffer all the tokens produced in this interval in order to preventAifrom blocking on writing. Thus,bumust be greater than or equal to prdB(︀Si,Sj⌋︀(Ai,Eu). Starting from

timet=Sj, both ofAiandAjare executing in parallel (i.e., overlapped execution). In

the proof of Theorem 4.3.1, an additionalXiu(qi)tokens were added to the buffer size of Euto account for the overlapped execution. However, this value is a “worst-case” value. The minimum number of tokens that needs to be buffered is given by the maximum number of unconsumed tokens inEu at any time over the time interval(︀Sj,Sj+α)

(i.e., intervalst2andt3in Figure 4.11). Taking the maximum number of unconsumed tokens guarantees thatAi will always have enough space to write toEu. Thus,buis sufficient and minimum for guaranteeing strictly periodic execution ofAiandAjin the time interval(︀Si,Sj+α). At timet=Sj+α, both ofAiandAjhave completed one

iteration and the number of tokens inEuis the same as at timet=Sj(follows from

Corollary 2.3.1 on page 28). Due to the periodicity ofAi andAj, the pattern shown in Figure 4.11 repeats. Thus,buis also sufficient and minimum for anyt≥Sj+α.

Case II:Si>SjFigure 4.12 illustrates this case. According to Lemma 4.4.2,Sjcan

be smaller thanSi if and only ifAiconsumes zero tokens in intervalt1. Therefore, the intervals in which there is actually production/consumption of tokens aret2andt3. During intervalt2, there is overlapped execution andbugives the maximum number of unconsumed tokens in Eu during(︀Si,Sj+α) which guarantees thatAi always

64 Chapter 4. Scheduling Framework

Table 4.2:Computing the buffer sizes for the CSDF graph shown in Figure 2.1 on page 29 under

different values ofη.⃗ ⃗ η b⃗ ⃗1 (︀2, 2, 5, 3, 2⌋︀T ⃗ 0.5 (︀2, 2, 5, 3, 2⌋︀T ⃗ 0 (︀2, 2, 5, 3, 2⌋︀T

timet = Sj+α,Aj finishes one iteration and intervalt3 starts. During interval t3, Aiis producing data toEuwhileAjis consuming zero tokens. Therefore,Euhas to

accommodate all the tokens produced during intervalt3andbumust be greater than or equal to prdB(︀Sj+α,Si+α⌋︀(Ai,Eu). As in Case I,bu is sufficient and minimum for

guaranteeing periodic execution ofAi and Aj in the interval(︀Sj,Si +α⌋︀. At time t=Si+α, both ofAi andAjhave completed one iteration andEucontains a number

of tokens equal to the number of tokens at timet=Si. Due to the periodicity ofAi

andAj, their execution pattern repeats. Thus,bu is also sufficient and minimum for

anyt≥Si+α. ∎

Example4.5.1. We give now an example on how to compute the buffer sizes for a given CSDF graph. Consider the CSDF graph shown in Figure 2.1 on page 29. Recall that we computedP⃗,D⃗andS⃗in Examples 4.3.1 and 4.4.1. Therefore, we show in Table 4.2 the

values⃗bunder different values ofη. Observe in this particular example that the buffer

sizes do not change whenη⃗is varied. However, the buffer sizes, in general, are reduced

whenη⃗is reduced. ◻

Now, we present the following theorem which represents the main results in this chapter.

Theorem 4.5.1. For a graph G, let T be a periodic taskset such that Ti ∈T corresponds to Ai ∈A. Tiis given by:

Ti = (Si,Ci,Di,Pi), (4.36) where Siis the earliest start time of Aigiven by (4.23), Ci ∈ ⃗C is the WCET given by (4.3), Di is the deadline given by (4.22), and Piis the period given by (4.17). T is schedulable on m processors using any hard-real-time scheduling algorithm𝒜for asynchronous sets of periodic tasks if:

1. every communication channel Eu∈E has a capacity of at least butokens, where buis given by (4.35)

2. T satisfies the schedulability test of𝒜on m processors