a new edf feasibility test

24
ISSN 0249-6399 ISRN INRIA/RR--5125--FR+ENG apport de recherche INSTITUT NATIONAL DE RECHERCHE EN INFORMATIQUE ET EN AUTOMATIQUE A New EDF Feasibility Test Bruno Gaujal , Nicolas Navet No 5125 February 27, 2004 TH ` EME 1

Upload: others

Post on 27-Jul-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A New EDF Feasibility Test

ISS

N 0

249-

6399

ISR

N IN

RIA

/RR

--51

25--

FR

+E

NG

ap por t de r ech er ch e

INSTITUT NATIONAL DE RECHERCHE EN INFORMATIQUE ET EN AUTOMATIQUE

A New EDF Feasibility Test

Bruno Gaujal , Nicolas Navet

No 5125

February 27, 2004

THEME 1

Page 2: A New EDF Feasibility Test
Page 3: A New EDF Feasibility Test

A New EDF Feasibility TestBruno Gaujal ∗ , Ni olas Navet †Thème 1 � Réseaux et systèmesProjet TRIORapport de re her he n�5125 � February 27, 2004 � 21 pagesAbstra t: We present a new algorithm for testing the feasibility of a set of non-re urrent tasks (or jobs) with real-time onstraints s heduled under the EDF poli y(Earliest Deadline First). The proposed feasibility test has a lower omplexity thanthe previously known test. The �rst step of the algorithm is to onstru t the Hassediagram of the set of tasks where the partial order is de�ned by the in lusion relationon the tasks. Then, the algorithm onstru ts the shortest path in a geometri alrepresentation at ea h level of the Hasse diagram. Depending on the maximal slopeof ea h path, the set of tasks is either feasible of not.The worst- ase omplexity of this feasibility test depends on stru tural hara -teristi s of the set of jobs sin e it is the sum of the levels in the Hasse diagram.Whatever the set of jobs, this is better than the worst- ase omplexities of existingapproa hes. Furthermore, we provide a probabilisti analysis of the omplexity whenthe tasks are random. For Poisson arrivals and exponentially distributed laten ies,we show that the asymptoti omplexity for assessing feasibility is O(N log(N)).As an interesting by-produ t, the algorithm provides a new way to derive thebest speeds of the pro essor so as to minimize the total energy onsumption whilemeeting the deadline of ea h task. The exa t omplexity of this algorithm (sub- ubi in the number of tasks) is lower than the omplexity of all the algorithms solving thesame problem, known by the authors.Key-words: Real-Time Systems, S heduling, Feasibility, Dynami Voltage S aling,Earliest Deadline First.∗ ENS Lyon - LIP, 46 Allée d'Italie, 69007 Lyon, Fran e. Email: Bruno.Gaujal�ens-lyon.fr† LORIA, Ensem, 2 avenue de la Forêt de la Haye, 54516 Vandoeuvre, Fran e. Email: Ni o-las.Navet�loria.fr

Unite de recherche INRIA LorraineTechnopole de Nancy-Brabois, Campus scientifique,

615 rue de Jardin Botanique, BP 101, 54600 VILLERS LES NANCY (France)Telephone : 03 83 59 30 30 - International : +33 3 3 83 59 30 30Telecopie : 03 83 27 83 19 - International : +33 3 83 27 83 19

Antenne de Metz, technopole de Metz 2000, 4 rue Marconi, 55070 METZTelephone : 03 87 20 35 00 - International: +33 3 87 20 35 00Telecopie : 03 87 76 39 77 - International : +33 3 87 76 39 77

Page 4: A New EDF Feasibility Test

2 B. Gaujal, N. Navet(Résumé : tsvp)

INRIA

Page 5: A New EDF Feasibility Test

Un nouveau test de faisabilité sous EDFRésumé : Nous présentons un nouvel algorithme pour tester la faisabilité d'un en-semble de tâ hes non-ré urrentes ordonnan ées sous EDF. Le test proposé à une omplexité plus faible que le test onnu jusqu'à présent. La première étape del'algorithme est de onstruire le diagramme de Hasse de l'ensemble des tâ hes oùl'ordre partiel est dé�ni par la relation d'in lusion sur les tâ hes. L'algorithme on-struit alors le plus ourt hemin d'une façon géométrique pour haque niveau dudiagramme de Hasse. En fon tion de la pente maximale de ha un des plus ourts hemins, l'ensemble de tâ hes est faisable ou non.La omplexité dans le pire as dépend de ara téristiques stru turelles de l'ensembledes tâ hes ar elle est fon tion du nombre de tâ hes à ha un des niveaux du dia-gramme de Hasse. Quel que soit l'ensemble de tâ hes, la omplexité dans le pire as est plus faible que elle des appro hes existantes. De plus, nous présentons uneanalyse probabiliste quand les ara téristiques des tâ hes sont aléatoires. Pour desarrivées Poissoniennes et des é héan es exponentiellement distribuées, nous montronsque la omplexité asymptotique pour dé ider de la faisabilité est O(N log(N)) où Nest le nombre de tâ hes.Une impli ation intéressante de et algorithme est qu'il fournit une nouvelle façonde al uler les meilleures vitesses du pro esseur pour minimiser la onsommation to-tale d'énergie tout en respe tant les é héan es. La omplexité exa te de l'algorithme,inférieure à O(N3), est plus faible que la omplexité des algorithmes onnus par lesauteurs pour résoudre le même problème.Mots- lé : Systèmes Temps Réel, Ordonnan ement, Adaptation Dynamique duVoltage, Earliest Deadline First.

Page 6: A New EDF Feasibility Test

4 B. Gaujal, N. Navet1 Introdu tionDe�nition of the problem. Two important problems related to the s heduling ofa set of independent jobs under EDF are addressed in this study : 1) the feasibilityanalysis and 2) the minimization of the energy onsumption.Existing solutions have shown that these problems are losely orrelated; theoptimal energy minimization algorithm from Yao et al. [8℄ embeds the feasibilityanalysis from Spuri [5℄ although both results have been developed independently.This hara teristi that the solutions of the two problems are tightly linked remainstrue with the new algorithms developed in this study.Existing work. In [5℄, an algorithm for testing the feasibility of a set of jobss heduled under EDF is presented; it will be alled the Spuri's algorithm in thefollowing sin e it relies on a Theorem stated by Spuri (Theorem 3.5 pp 33 in [5℄).The omplexity of this algorithm is O(N2) where N is the ardinal of the set of jobs.The study published in [8℄ provides, for independent tasks with deadlines, theEDF s hedule that minimizes energy usage while ensuring that deadlines are notmissed. This algorithm, termed the Yao's algorithm, runs in O(N3) in the worst- ase (for more details on the omplexity analysis, please refer to the end of Se tion 2).The Yao's algorithm also provides a feasibility test under EDF sin e, intuitively, iffor meeting deadlines the CPU speed needs to be greater than its maximum speedthen the set of jobs is not feasible.Re ently, a new approa h for solving both problems under the light of a shortestpath problem has been proposed in [3℄ but it is restri ted to tasks with FIFO real-time onstraints (ai ≤ aj → di ≤ dj). For su h tasks, feasibility testing and energyminimization an be solved in O(N log(N)).Contribution of the paper. This work is the ontinuation of [3℄ where the spe ial ase of FIFO onstraints has been treated. Here, a solution to the general ase isprovided, i.e. the FIFO assumption is removed. Note that the omplexity of thealgorithms depends on stru tural properties of the set of jobs. The exa t omplexitiesof the algorithms on a parti ular set of jobs is provided and, whatever the set ofjobs, it is better than the omplexities of existing approa hes (sub-quadrati in thenumber of tasks for feasibility and sub- ubi for energy minimization). Furthermore,we provide a probabilisti analysis of the omplexities when the tasks are random.We show that the average omplexity is always smaller that O(N√

N). Howeverthis bound is not tight be ause it does not take into a ount the fa t that deadlinesINRIA

Page 7: A New EDF Feasibility Test

A New EDF Feasibility Test 5have to be larger than arrival times. In the ase of Poisson arrivals and exponentiallydistributed laten ies, we show that the asymptoti omplexity for assessing feasibilityis O(N log(N)).Model of the system. We onsider a single CPU dedi ated to the exe utionof a a �nite set of some non-re urrent independent tasks (or �jobs�) with real-time onstraints. The CPU pro essing speed u an vary over a ontinuous range from 0to 1 (the maximal speed of the pro essor to �xed to 1 with no loss of generality;this an be a hieved by a re-s aling of the size of the jobs). The set of tasks isT = {τ1, . . . , τN} and ea h task τi is hara terized by a triplet (ai, si, di) wherethe quantities ai, si, di respe tively denote the arrival time, the size (time needed toexe ute the task at the maximum speed) and the deadline of task τi.Organization of the paper. The Yao's algorithm for energy minimization isreminded in Se tion 2. Se tion 3 is devoted to our proposal of feasibility test underthe EDF poli y. The orre tness of the algorithm is proved and its omplexity isassessed both deterministi ally and probabilisti ally. Finally, in se tion 4, an originalalgorithm to the problem of minimizing the energy onsumption under real-time onstraints is proposed.2 Existing resultsIn this Se tion, we explain the Yao's algorithm for energy minimization. We hose topresent this onstru tion with full details so that the di�eren es with our approa h an be easily highlighted and also sin e several on epts and notations presented herewill be used in subsequent Se tions. Note that the Spuri's algorithm for feasibilityis the �rst iteration of the loop of the algorithm in paragraph 2.2.The speed of the CPU at time t is denoted v(t). We re all the onstru tion ofthe optimal fun tion vYao(t) given by Yao et al. in [8℄. This onstru tion minimizesenergy onsumption while ensuring that no deadline will be missed. Basi ally, thealgorithm works by identifying the time interval, termed the riti al interval, overwhi h the highest pro essing speed is required. The lowest admissible frequen y is omputed for this interval, the tasks belonging to this interval (i.e. arrival date anddeadline inside the interval) are then removed (this step is termed �time ompression�in the following) and a sub-problem is onstru ted with the remaining tasks.RR n�5125

Page 8: A New EDF Feasibility Test

6 B. Gaujal, N. Navet2.1 Time ompressionHere we explain how to suppress the interval [a, d] from the time-line and how tomodify the set of tasks a ordingly. It has been hosen to denote the bounds of theinterval by a and d sin e, in the following, a and d will ne essarily be arrival datesand deadline dates respe tively. The notation τi ⊆ [a, d] means that task τi belongsto [a, d] (ai ≥ a, di ≤ d). When suppressing [a, d], the task set is modi�ed in thefollowing manner :• if τi ⊆ [a, d] then τi is removed,• for all remaining tasks, si is un hanged and� if ai ∈ [a, d] then ai := a,� else if ai ≥ d then ai := ai − (d − a),� if di ∈ [a, d] then di := a,� else if di ≥ d then di := di − (d − a).The time- ompression pro edure is illustrated in Figure 1.

di

ai di di+1ai+1ai+3

di+3ai ai+4 di+4

a dai+3

di+3

ai+2

t

t

di+2di+1ai+1

ai+4 di+4Figure 1: Example of time ompression. When suppressing the interval [a, b], thetask τi+2 is removed from the set of tasks..2.2 Yao's algorithmThe Yao's algorithm an be des ribed in a onvenient way using the following " om-position" of fun tions. Let f and g be real fun tions with appropriate domains andlet [a, d] be a time interval, then fun tion g ∧[a,d] f is de�ned as follows : INRIA

Page 9: A New EDF Feasibility Test

A New EDF Feasibility Test 7• if t < a, then g ∧[a,d] f(t) = g(t),• if t ∈ [a, d], then g ∧[a,d] f(t) = f(t),• if t > d, then g ∧[a,d] f(t) = g(t − (d − a)).Note that this operation is not asso iative and leaves impli it the domain of allfun tions involved. If we de�ne h := g ∧[a,d] f this means that f is de�ned on [a, d],

g is de�ned over an interval in luding a, say [b, c], and h is de�ned over [b, c+ d− a].Yao et al. de�ne the "intensity" of an interval as the workload brought by thetasks belonging to the interval divided by the length of the interval. Intuitively, it isthe smallest amount of work that has to be done during the interval for meeting thetiming onstraints. The intensity over [a, d] is denoted W[a,d] and it is equal to :W[a,d] =

∑{τk⊆[a,d]} sk

d − aThe algorithm proposed in [8℄ onstru ts the fun tion vYao(t) whi h is the optimalspeed for minimizing the total energy onsumption while respe ting deadlines. Thisalgorithm an be de omposed in the following steps :1. n := 12. Compute the riti al interval In := [ai, dj ] where ai and dj are su h thatW[ai,dj ] = max

0≤a≤dW[a,d]. (1)In (1), only values of a and d that are respe tively arrival dates and deadlinedates have to be onsidered sin e W[a,d] possesses lo al maxima on su h points.3. Over the riti al interval at step n, In = [ai, dj ], the fun tion fn is onstant

fn(t) := W[ai,dj ].4. Using time- ompression, In is removed, let n := n + 1, return to step 2 if atleast one task remains or go to step 4 otherwise.5. Fun tion vYao is ompletely de�ned : vYao := fn ∧In−1(· · · ∧I1 f1).

RR n�5125

Page 10: A New EDF Feasibility Test

8 B. Gaujal, N. NavetThe above algorithm is ubi in the number of tasks N : there are at most Nexe ution of step 2 whi h runs in O(N2) sin e for ea h arrival date there are at mostN deadlines to onsider. In [8℄, the authors laim, without more details, that using�a suitable data stru ture su h as the segment tree�, the running time an be redu edto O(N log2(N)). However, this was never really a hieved as mentioned in [7℄. Wea tually do not know how to obtain an implementation with their algorithm in lessthan O(N3) and we are not aware of any paper in the literature that has addressedthe problem with a omplexity lower than O(N3).The rest of the paper is almost entirely devoted to the presentation of a newalgorithm with a sub-quadrati omplexity to ompute a fun tion whi h oin idewith vYao on the riti al interval. This will provide a feasibility test under EDFin sub-quadrati time whi h is an improvement over existing algorithms running inquadrati time ([8, 5℄).3 New algorithm for feasibilityThe algorithm presented here relies on the onstru tion of the Hasse diagram of apartially ordered set (poset) and on the solution of a shortest path problem that hasbeen proposed in [3℄. These two points will be �rst reminded. We then provide the ore of the algorithm, prove its orre tness and we evaluate its algorithmi omplexityboth in a deterministi and in a probabilisti way.3.1 The Hasse diagramLet us onsider the poset P on the set of tasks with the partial order being de�nedby the stri t in lusion of the intervals : P = {[ai, di], (}, where [a, d] ( [a′, d′] ifa′ < a and d′ > d. A �nite poset an be represented by a Hasse diagram (see [6℄for more details) and the levels in the diagram are denoted L1, · · · , LK where K isthe highest level. One denotes by L(i) the level of the interval [ai, di] in P , it willbe alled the level of task τi. The set of tasks that will be onsidered for illustrationpurpose in the following is :

INRIA

Page 11: A New EDF Feasibility Test

A New EDF Feasibility Test 9a d s

τ1 0 22 3τ2 2 10 1τ3 4 6 1τ4 5 13 4τ5 8 19 1τ6 11 15 2τ7 15 24 1The Hasse diagram asso iated with this set of tasks is given in Figure 2 b) whileFigure 2 a) shows how the intervals [ai, di] overlap.

Level 1

Level 2

Level 3

a)

b)

τ6

τ5τ2

τ1 τ7

τ4

τ3

τ3

τ5

τ1

τ7

τ2

τ5

τ4

Figure 2: Sub-�gure a) represents the overlapping of the intervals [ai, di] while sub-�gure b) shows the orresponding Hasse diagram.We now explain how to ompute the levels of all the tasks in the Hasse diagramin O(N log(N)) elementary operations.An array L will be used to store the levels of the tasks : L[i] is the level of τi.An array T stores the value of largest deadline on a given level. The arrays L and Tare iteratively onstru ted during the exe ution of the algorithm given below :1. Reorder the set of tasks so that all the indexes of the tasks are given a ordingto the arrival times ai where ties are broken using the deadlines.RR n�5125

Page 12: A New EDF Feasibility Test

10 B. Gaujal, N. Navet2. T [0] := ∞, T [1] := d1, L[1] := 1 and for all k = 1..N set T [k] := 0.3. For i from 2 to N do(a) Di hotomy-Sear h of di in the urrent T gives k, the index su h thatT [k] > di ≥ T [k + 1].(b) T [k + 1] := di; L[i] = k + 1.Note that the di hotomi sear h is valid be ause T is sorted in in reasing order.The orre tness of this onstru tion omes from the fa t that all interval orders (ashere) are two dimensional (see for example [2℄).The total omplexity of the algorithm is O(N log(N)) : the initial sort is in

O(N log(N)) and ea h di hotomy uses O(log(N)) operations and it is repeated Ntimes.3.2 The shortest path onstru tionIn [3℄, where the ase K = 1 is treated (FIFO tasks), the algorithm involves the on-stru tion of the shortest path among all the paths between 0 and T with given upperand lower bounds. The onstru tion in the general ase also uses this framework,but, this time, we need to onstru t su h a path for ea h level in the Hasse diagram.For onvenien e, one assumes that a1 = 0 (all dates an be shifted to the left)and let Tdef= maxi{di}. For all tasks with level not smaller than k in the Hassediagram, we onstru t two fun tions Ak(t) and Dk(t) over the interval [0, T ] usingthe following de�nition:

Ak(t) =∑

L(i)≥k

si · 1[ai<t],

Dk(t) =∑

L(i)≥k

si · 1[di≤t].The fun tions Ak(t) and Dk(t) are stair ase fun tions (i.e. pie e-wise onstant, witha �nite number of pie es). Also note that A is left- ontinuous while D is right- ontinuous.Let g be an arbitrary non-de reasing and stri tly onvex fun tion. In power awares heduling, this fun tion is generally onsidered for modeling the energy onsumptionof the pro essor. The onsumption at time t depends on the pro essor speed u(t)and for instan e with the CMOS te hnology, typi ally, g(u(t)) ≈ αCu(t)1+2/(γ−1),where 1 ≤ γ ≤ 3, α ≥ 0, C ≥ 0, see [4℄ for more details.INRIA

Page 13: A New EDF Feasibility Test

A New EDF Feasibility Test 11Mathemati al Program 1. Program Pk: Find an integrable fun tion u∗k : [0, T ] →

R su h that ∫ T

0g(u∗

k(s))ds is minimized, (2)under the onstraintsu∗

k(t) ≥ 0 ∀t ∈ [0, T ], (3)∫ t

0u∗

k(s)ds ≤ Ak(t) ∀t ∈ [0, T ], (4)∫ t

0u∗

k(s)ds ≥ Dk(t) ∀t ∈ [0, T ]. (5)Theorem 1. The following results are all shown in [3℄.i For all k, the optimal solution of program Pk is unique (up to a set of measure0).ii If u∗k is the optimal solution of program Pk where g is stri tly onvex andnon-de reasing, then u∗

k is also an optimal solution of Pk for any other non-de reasing onvex fun tion.iii The optimal solution u∗k satis�es the following inequality1:

sup0≤t≤T u∗k(t) ≤ sup0≤t≤T uk(t), for all fun tions uk satisfying onstraints (3),(4) and (5).iv The integral U∗

kdef=

∫ t0 u∗

k(s)ds gives the shortest path from 0 to T while stayingbetween Ak and Dk (see Figure 3 for an illustration).Theorem 2. ([3℄) If the fun tions Ak and Dk are given under the form of twoordered lists of points, the onstru tion of u∗k(t) an be done in linear time [3℄.The algorithm to onstru t u∗

k presented in [3℄ is inspired from the linear timealgorithm omputing the onvex hull of n ordered points in the plane.1here, the sup operator stands for the entral supremum, sin e all fun tions are only de�nedalmost everywhere.RR n�5125

Page 14: A New EDF Feasibility Test

12 B. Gaujal, N. Navet3.3 Des ription of the feasibility algorithmOne re alls that K is the highest level in the Hasse diagram. We all Tk, 1 ≤ k ≤ Kthe set of all the tasks at levels k and higher. The algorithm for de iding the feasibilityis the following :1. For all k ∈ {1 · · · ,K}(a) Constru t u∗k(t) the optimal solution of Pk.(b) De�ne rk := sup0≤t≤T u∗

k(t).2. The set of tasks is feasible if and only if supKk=1 rk ≤ 1.An example of this onstru tion is given in Figure 3 and Figure 4 using the sameset of tasks as in Figure 2. The fun tions U∗

i =∫ t0 u∗

i (x)dx are displayed instead ofu∗

i (t) in order to show why su h fun tions are alled shortest paths.Figure 3 represents U∗3 (t) and U∗

2 (t) while Figure 4 shows the onstru tion ofU∗

1 (t). We get r3 = 1/2, r2 = 7/11 and r1 = 12/22. Note that the maximumr2 = 7/11, is rea hed by u∗

2 over the interval [4, 15] that in ludes tasks τ3, τ4 and τ6.A tually, this is the riti al interval. In our example, the set of tasks is feasible sin er2 = 7/11 < 1.3.4 Corre tness of the algorithmThis se tion is devoted to the proof of the orre tness of the algorithm. In thefollowing, Ic denotes the riti al interval and WIc , the intensity over the riti alinterval is denoted Wc. We also de�ne the fun tion vkYao, as the Yao's onstru tionover the set of tasks Tk, 1 ≤ k ≤ K. Therefore, v1Yao = vYao.Lemma 1. The following assertions are true:i- supt vYao(t) = Wc.ii- vYao(t) ≤ 1 if and only if the set of tasks is feasible.iii- For all k, vkYao is a solution of Program Pk (not ne essarily optimal).iv- For all 1 < k ≤ K, supt vkYao(t) ≤ supt vk−1Yao (t).Proof. The proof of points i is a dire t onsequen e of the onstru tion of vYao (see[8℄). Point ii has been shown in [5℄. Point iii follows from the fa t that all feasibles heduling poli ies with a pro essor with speed u should satisfy onstraints 3,4 and5. As for iv, this is simply be ause Tk ⊆ Tk−1 and the maximal intensity grows whennew tasks are added.

INRIA

Page 15: A New EDF Feasibility Test

A New EDF Feasibility Test 13a)

b)

A3(t)

D3(t)1

3

U∗2 (t)

A2(t)

1

2

7

9

6

D2(t)

U∗3 (t)

Figure 3: Constru tion of u∗3(t) and u∗

2(t). Sub-�gure a) shows U∗3 (t) =

∫ t0 u∗

3(x)dxand sub-�gure b) U∗2 (t) =

∫ t0 v2(x)dx.

A1(t)

D1(t)

U∗1 (t)

u∗

2(t) > u∗

1(t)Figure 4: Constru tion of U∗

1 (t) =∫ t0 u∗

1(x)dx

RR n�5125

Page 16: A New EDF Feasibility Test

14 B. Gaujal, N. NavetLemma 2. For all t ∈ [0, T ], supt u∗k(t) ≤ supt vkYao(t).Proof. This is a dire t onsequen e of Lemma 1(iii ) and Theorem 1(iii).Lemma 3. supk rk ≥ Wc.Proof. We onsider all the tasks in luded in the riti al interval Ic = [ac, dc] as onesuper-task τc whi h size sc is the sum of the sizes of all tasks in luded in Ic whileits arrival is ac and its deadline is dc. Note that the level Lc of this new task is thelowest level of all tasks in Ic.By de�nition of τc, all non riti al task in TLc are not in luded in τc: non riti altasks starting before τc end before τc and non riti al tasks starting before the end of

τc have arrived after τc. This means that DLc(dc)−ALc(ac) ≥ sc. The onstru tionof u∗Lc

implies that supt∈Icu∗

Lc(t) ≥ DLc(dc) − ALc(ac)/dc − ac ≥ Wc.Finally, supk rk ≥ rLc ≥ supt∈Ic

u∗Lc

(t) ≥ Wc.Theorem 3. The set of tasks is feasible if and only if sup0≤k≤K rk ≤ 1.Proof. This is a dire t onsequen e of Lemmas 1(i), 1(ii), 2 and 3.Note that u∗k 6= vkYao in general. However, as shown above, the equality holdsinside the riti al interval for some k.3.5 Deterministi analysis of the omplexityAssume that tasks have already been sorted by their arrival date as well as by theirdeadlines. Assume that the levels in the Hasse diagram are also given. The time omplexity of onstru ting u∗

k is linear in the number of tasks at level k and higheras shown in [3℄. Computing rk is also linear in the number of tasks at levels largerthan k. Therefore, the omplexity of the algorithm to onstru t v1 is (up to amultipli ative onstant)N∑

i=1

L(τi) =K∑

k=1

Ni · kwhere Ni is the number of tasks at level i. The highest omplexity orresponds tothe ase where there is one task at ea h level lower than K and NK = N − (K − 1)tasks at level K. The omplexity is thus O(KN − K2/2).Note that this time omplexity is linear if all tasks are on level 1 (K = 1) whi his the best possible ase. The worse ase arises when K = N with 1 tasks on ea hINRIA

Page 17: A New EDF Feasibility Test

A New EDF Feasibility Test 15level, where the omplexity be omes N2/2. However, it is easy to pat h this worse ase and solve the problem in linear time in that ase by merely testing r1 ≤ 1 .Maybe su h a pat h exists in all quadrati ases.Sin e K ≤ N , this means that the omplexity of the algorithm presented aboveis at most quadrati . An interesting problem, investigated below, is to estimate thevalue of K for typi al set of tasks.3.6 Probabilisti analysis of the omplexityIn this se tion, we provide an estimation of K when the hara teristi s of the tasksare hosen randomly. Re all that K is the number of levels in the Hasse diagramof the N tasks. Another way to de�ne it, is to see it as the longest in reasingsubsequen e in the partial order of the set P .It is a lassi al problem to estimate the average length of the longest subsequen ein an ordered set. If the arrivals ai are hosen randomly and the deadlines di arealso hosen randomly and are independent of the arrivals, then one has the followingresult.Lemma 4 ([1℄).E(K) = 2

√N + O(

√N).However, we an get a mu h lower estimation on the average K by taking intoa ount the fa t that the deadlines are not independent of the arrivals (di ≥ ai). Inthat ase, the average K is mu h smaller than √

N .For example, here is the proof in the ase the arrival pro ess is Poisson and therelative deadlines (di − ai) are exponentially distributed.Lemma 5. If the arrival pro ess is Poisson and the relative deadlines are exponen-tially distributed with the same parameter, then E(K) = O(log(N)).Proof. First, note that the problem an be seen as a two dimensional problem byplugging ai on the x-axis and −di on the y axis. In this new framework, K is thelongest sequen e of omponent-wise in reasing points (ai1 ,−di1) < · · · < (aiK ,−diK ).Now, if we onsider any given point (ah,−dh), the longest in reasing sequen e Shstarting in this point is learly smaller that the total number Th of points whi h arelarger than (ah,−dh). The rest of the proof is a dire t derivation giving an upperRR n�5125

Page 18: A New EDF Feasibility Test

16 B. Gaujal, N. Navetbound on Th.P(

Nmaxh=1

Sh ≥ C) ≤ NP(SH ≥ C) where His a random point≤ N

∫ ∞

x=0e−x

∞∑k=C−1

P(k arrivals in aninterval of length x))e−kxdx

≤ N

∫ ∞

x=0e−xP( more than C − 1 arrivalsin an interval of length x)e−(C−1)xdx

≤ N

∫ ∞

x=0e−Cx xC

C!dx =

N

(C)C+1Now, if C ≥ log(N), this probability goes to zero as N goes to in�nity. So thetail of K does not go beyond log(N) for large N . In parti ular, this implies thatE(K) = O(log(N)).This means that the average omplexity is O(N log(N)). A tually, this proofshows a stronger result: when the number of tasks N goes to in�nity, the omplexityof the algorithm is below N log(N) with probability one.Note that the average omplexity of the lassi al algorithm of Spuri is ne essarilygreater than C((N2 + N)/2) for some onstant C whatever the distributions sin ethis is the best possible omplexity ( orresponding to the ase where tasks have FIFO onstraints).4 Energy minimizationIn this se tion we onsider the following problem : hoose at ea h time t the speedu(t) in su h a way as to exe ute all tasks within their deadline onstraints whileminimizing the total energy onsumption.The fun tion vYao a tually provides a solution to the problem of minimizing thetotal energy used by the pro essor when the immediate energy onsumption of apro essor going at speed u, is of the form g(u), where g is onvex and in reasing.This is the result laimed in [8℄. In the following, we present two di�erent algorithms

INRIA

Page 19: A New EDF Feasibility Test

A New EDF Feasibility Test 17that enable to ompute the sequen e of optimal frequen ies with a lower omplexitythan Yao et al.'s algorithm.4.1 Algorithm 1A straightforward way to determine the optimal pro essor speeds is to iterate thealgorithm for assessing feasibility : on e the riti al interval is identi�ed it is removedand the feasibility algorithm is applied on the resulting sub-problem. This leads tothe following algorithm :1. For k = 1..K onstru t u∗k(t). Let ri = sup0≤t≤T u∗

k(t); the riti al interval[ai, bj] is su h that W[ai,bj ] = supk rk.2. Set the speed on [ai, bj ] equal to W[ai,bj ]. Using time ompression, removeinterval [ai, bj ]. Return to step 1 if at least one task remains.It should be noted that K, the number of levels in the Hasse diagram, annot in reaseafter the ompression of the riti al interval. Indeed if task τ1 is not stri tly in ludedin task τ2 before time ompression, then τ1 is not stri tly in luded in task τ2 after ompression. On the other hand, note that K may de rease by time ompression.Indeed, if τ1 is stri tly in luded in τ2 before time ompression and if the deadlines(or the arrival times) of both tasks fall in the ompressed interval, then they are notstri tly in luded anymore after time ompression.Sin e there is at most N riti al intervals, the feasibility algorithm (step 1) isinvoked at most N times and the worst- ase omplexity of the algorithm is O(KN2).In the average ase, where tasks are hosen randomly with Poisson distributions forthe arrival times and exponential laten ies, the average omplexity is O(N2 log N).The orre tness of this algorithm is implied by the orre tness of the feasibilityalgorithm (see Theorem 3).4.2 Algorithm 2Another way to de�ne vYao is by using a pro edure lose to the one used for feasibility.Mathemati al Program 2. For all 1 ≤ k ≤ K, onsider the integrable fun tion

vk : [0, T ] → R su h that∫ T

0g(vk(s))ds is minimized, (6)

RR n�5125

Page 20: A New EDF Feasibility Test

18 B. Gaujal, N. Navetunder the onstraintsvk(t) ≥ vk+1(t) ∀t ∈ [0, T ], (7)∫ t

0vk(s)ds ≤ Ak(t) ∀t ∈ [0, T ], (8)

∫ t

0vk(s)ds ≥ Dk(t) ∀t ∈ [0, T ]. (9)As for Mathemati al Program 1, one an he k that the fun tion vk is unique upto a set of measure 0.Theorem 4. The fun tions v1 and vYao oin ide: v1(t) = vYao(t), ∀0 ≤ t ≤ T .Proof. (sket h) Consider the riti al interval Ic in the domain of de�nition of alltasks, D = [0, T ]. A dire t indu tion on K shows that v1(t) = supk u∗

k(t) over the riti al interval Ic. By using Theorem 3, this shows that v1(t) = vYao(t) if t ∈ Ic.Now, we ompress time by Ic. we onsider the new set of tasks T \Ic ompressedby the interval Ic. The new domain of de�nition is denoted D\Ic. If f is any fun tionde�ned on D for the set of tasks T , we denote by f\Ic the same fun tion onstru tedon D\Ic for the ompressed set of tasks T \Ic.We �rst he k by indu tion on K that the fun tion v1 = (v1\Ic) ∧Ic v1. If no riti al tasks are at level 1, then v2 = (v2\Ic) ∧Ic v2 by indu tion. Furthermore,v1 = v2 over Ic be ause no tasks on level one are riti al. This means that v1 =(v1\Ic)∧Ic v1. If some riti al tasks are on level one, we play the same tri k as in theproof of lemma 3 and repla e all riti al tasks by one super-task of level 1. Then,v1 = (v1\Ic) over D\Ic and v1 = Wic , the rate of the riti al interval over Ic. Thisis dire t by using the onstraints used to de�ne v1.Also by onstru tion, it is lear that vYao = (vYao\Ic) ∧Ic vYao.Finally, using the fa t that vYao\Ic and v1\Ic also oin ide over the riti al intervalin D\Ic shows that vYao and v1 oin ide over both riti al intervals. By iterating this onstru tion, one sees that vYao and v1 are equal over all [0, T ].This gives an analyti al way to de�ne the onstraints for feasibility. Now, hereis a possible onstru tion of v1.1. For k from K downto 1 do(a) Constru t u∗

k(t). Set vk := u∗k.

INRIA

Page 21: A New EDF Feasibility Test

A New EDF Feasibility Test 19(b) As long as there exists an interval I over whi h vk(t) < vk+1(t), remove alltasks in luded in I of level not smaller than k+1 and use time- ompressionfor I. Do this for all su h intervals. and onstru t u∗k\I again over the ompressed set of tasks and set vk := (u∗

k\I) ∧I vk+1.2. Return v1.An example of onstru tion is given in Figure 5 using the same set of tasks as inFigure 2. The onstru tion goes as follows: v3 = u∗3 and therefore it is not displayedhere (see Figure 3.a). It also happens that v2 = u∗

2. The integral V2 is displayedin Figure 5 as well as U∗1 . Sin e v2 ≥ u∗

1 over the interval Ic = [4, 15], we haveto ompute u∗1\[4, 15] over the set of tasks ompressed by [4, 15]. The fun tion v1su h that v1 = v2 over [4, 15] and v1 = u∗

1\[4, 15] on the rest, is, by de�nition,v1 = (u∗

1\[4, 15])∧[4,15] v2. Now, we he k that v1 ≥ v2 and the algorithm stops. Theintegral V1 of v1 is displayed in Figure 5.

v2(t) > u∗

1(t)

V2(t)

V1(t)

U∗1 (t)

A1(t)

D1(t)

Figure 5: Constru tion of v1(t). The fun tion V1(t) =∫ t0 v1(x)dx is represented.The algorithmi omplexity of this onstru tion is in the worse ase

C(

K−1∑k=1

nknk+1)

RR n�5125

Page 22: A New EDF Feasibility Test

20 B. Gaujal, N. Navetwhere nk is the number of tasks on level k and higher and C is a onstant. In theworse ase, this omplexity, up to the onstant C, is again O(KN2). However, it isimportant to noti e that sin e the time omplexity has a di�erent stru ture than the onstru tion presented in Se tion 4.1. Indeed, it only depends on the initial Hassediagram of all that tasks while the previous onstru tion depends on the su essiveHasse diagrams after the times ompressions. Therefore, this onstru tion is fasterthan the onstru tion presented in Se tion 4.1 in some ases (for example if thesu essive riti al intervals involve a single task at ea h step).In the average ase, where tasks are hosen randomly with Poisson distribu-tions for the arrival times and exponential laten ies, the average omplexity is alsoO(N2 log N).4.3 ExtensionsIf g is not onvex or if only a �nite number of speeds are available, then, it is stillpossible to pat h both solutions by repla ing g by its onvex hull, as done in [3℄ or omputing the best solution with a �nite number of speeds as done in [3℄.5 Con lusionIn this study we proposed a new algorithm for assessing the feasibility of a set ofindependent jobs s heduled under EDF. This algorithm outperforms the existing ap-proa h of Spuri in terms of omplexity. In future work, it may be possible that further omplexity improvements an be a hieved with lo al optimization pro edures whentasks exhibit spe i� hara teristi s (for instan e when some tasks are imbri ated).The other ontribution of this study is a new algorithm for �nding the optimalvoltage s hedule. This proposal possesses a lower omplexity than the lassi al algo-rithm of Yao et al. and it enables several extensions su h as �nite number of speeds(see [3℄).A knowledgmentsThe authors would like to thank James Martin who pointed out referen e [1℄ andhelped with the omputations for the average omplexity.

INRIA

Page 23: A New EDF Feasibility Test

A New EDF Feasibility Test 21Referen es[1℄ D. Aldous and P. Dia onis. Hammersley's intera ting parti le pro ess and longestin reasing subsequen es. Probability Theory and Related Fields, (103):199�213,1995.[2℄ P. Fishburn. Interval Orders and Interval Graphs: A Study of Partially OrderedSets. Inters ien e Series in Dis rete Mathemati s. Wiley, 1985.[3℄ B. Gaujal, N. Navet, and C. Walsh. Shortest path algorithms for real-times heduling with minimal energy use. submitted to ACM TECS, 2003. Availableas INRIA Resear h Report RR-4886.[4℄ F. Gruian. Energy-Centri S heduling for Real-Time Systems. PhD thesis, LundInstitute of Te hnology, 2002.[5℄ J.A. Stankovi , M. Spuri, K. Ramamritham, and G.C. Buttazo. Deadline S hedul-ing for Real-Time Systems: EDF and Related Algorithms. Kluwer A ademi Publisher, 1998.[6℄ E. Weisstein. The CRC Con ise En y lopedia of Mathemati s. CRC Press, 1999.ISBN 0-8493-9640-9.[7℄ F. Yao. Complexity of the Yao Demers Shenker algorithm. Private ommuni a-tion, 2003.[8℄ F. Yao, A. Demers, and S. Shenker. A s heduling model for redu ed CPU energy.In Pro eedings of lEEE Annual Foundations of Computer S ien e, pages 374�382,1995.

RR n�5125

Page 24: A New EDF Feasibility Test

Unite de recherche INRIA Lorraine, Technopole de Nancy-Brabois, Campus scientifique,615 rue du Jardin Botanique, BP 101, 54600 VILLERS LES NANCY

Unite de recherche INRIA Rennes, Irisa, Campus universitaire de Beaulieu, 35042 RENNES CedexUnite de recherche INRIA Rhone-Alpes, 655, avenue de l’Europe, 38330 MONTBONNOT ST MARTIN

Unite de recherche INRIA Rocquencourt, Domaine de Voluceau, Rocquencourt, BP 105, 78153 LE CHESNAY CedexUnite de recherche INRIA Sophia-Antipolis, 2004 route desLucioles, BP 93, 06902 SOPHIA-ANTIPOLIS Cedex

EditeurINRIA, Domaine de Voluceau, Rocquencourt, BP 105, 78153 LE CHESNAY Cedex (France)

http://www.inria.fr

ISSN 0249-6399