34
fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund, Informatik 12 Germany Graphics: © Alexandra Nolte, Gesine Marwedel, 2003 These slides use Microsoft clip arts. Microsoft copyright restrictions apply. 2010 年 12 年 15 年

Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

Embed Size (px)

Citation preview

Page 1: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

fakultät für informatikinformatik 12

technische universität dortmund

Classical scheduling algorithms

for periodic systems

Peter MarwedelTU Dortmund, Informatik 12

Germany

Gra

phic

s: ©

Ale

xand

ra N

olte

, Ges

ine

Mar

wed

el, 2

003

These slides use Microsoft clip arts. Microsoft copyright restrictions apply. 2010 年 12 月 15 日

Page 2: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 2 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Structure of this course

2:Specification

3: ES-hardware

4: system software (RTOS, middleware, …)

8:Test

5: Evaluation & validation & (energy, cost, performance, …)

7: Optimization

6: Application mapping

App

licat

ion

Kno

wle

dge Design

repositoryDesign

Numbers denote sequence of chapters

Page 3: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 3 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Classes of mapping algorithmsconsidered in this course

Classical scheduling algorithmsMostly for independent tasks & ignoring communication, mostly for mono- and homogeneous multiprocessors

Dependent tasks as considered in architectural synthesisInitially designed in different context, but applicable

Hardware/software partitioningDependent tasks, heterogeneous systems,focus on resource assignment

Design space exploration using evolutionary algorithms; Heterogeneous systems, incl. communication modeling

Page 4: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 4 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Periodic scheduling

Each execution instance of a task is called a job.

Notion of optimality for aperiodic scheduling does not make sense for periodic scheduling.

For periodic scheduling, the best that we can do is to design an algorithm which will always find a schedule if one exists. A scheduler is defined to be optimal iff it will find a schedule if one exists.

T1

T2

Page 5: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 5 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Periodic scheduling- Scheduling with no precedence constraints -

Let {Ti } be a set of tasks. Let: pi be the period of task Ti, ci be the execution time of Ti , di be the deadline interval, that is,

the time between Ti becoming available and the time until which Ti has to finish execution.

li be the laxity or slack, defined as li = di - ci

fi be the finishing time.

li

di

cit

i

pi

Page 6: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 6 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Average utilization, a very important characterization of scheduling problems:

Average utilization:

n

i i

i

p

c

1

Necessary condition for schedulability(with m=number of processors):

m

Page 7: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 7 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Independent tasks:Rate monotonic (RM) scheduling

Most well-known technique for scheduling independentperiodic tasks [Liu, 1973].Assumptions: All tasks that have hard deadlines are periodic.

All tasks are independent.

di =pi, for all tasks.

ci is constant and is known for all tasks.

The time required for context switching is negligible.

For a single processor and for n tasks, the following equation holds for the average utilization µ:

)12( /1

1

nn

i i

i np

c

Page 8: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 8 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Rate monotonic (RM) scheduling- The policy -

RM policy: The priority of a task is a monotonically decreasing function of its period.

At any time, a highest priority task among all those that are ready for execution is allocated.

Theorem: If all RM assumptions are met, schedulability is guaranteed.

Page 9: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 9 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Maximum utilization for guaranteed schedulability

Maximum utilization as a function of the number of tasks:

)2ln()12((lim

)12(

/1

/1

1

n

n

nn

i i

i

n

np

c

Page 10: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 10 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Example of RM-generated schedule

T1 preempts T2 and T3.T2 and T3 do not preempt each other.

t

Page 11: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 11 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Failing RMS

Task 1: period 5, execution time 3Task 2: period 8, execution time 3µ=3/5+3/8=24/40+15/40=39/40 0.975 2(21/2-1) 0.828

Page 12: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 12 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Case of failing RM scheduling

Task 1: period 5, execution time 2Task 2: period 7, execution time 4µ=2/5+4/7=34/35 0.97 2(21/2-1) 0.828

Missed deadline

Missing computations scheduled in the next period

leviRTS animation

t

Page 13: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 13 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Intuitively: Why does RM fail ?

No problem if p2 = m p1, mℕ :

T1

T2

t fits

T1

T2

t

should be completed

Switching to T1 too early, despite early deadline for T2

t

t

Page 14: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 14 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Critical instants

Definition: A critical instant of a task is the time at which the release of a task will produce the largest response time.

Lemma: For any task, the critical instant occurs if that task is simultaneously released with all higher priority tasks.

Proof: Let T={T1, …,Tn}: periodic tasks with i: pi ≦ pi +1.

Source: G. Buttazzo, Hard Real-time Computing Systems, Kluwer, 2002

Page 15: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 15 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Critical instances (1)

Response time of Tn is delayed by tasks Ti of higher priority:

cn+2ci

Tn

Ti

t

Maximum delay achieved if Tn and Ti start simultaneously.

Maximum delay achieved if Tn and Ti start simultaneously.

cn+3ci

Tn

Ti

Delay may increase if Ti starts earlierDelay may increase if Ti starts earlier

t

Page 16: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 16 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Critical instants (2)

Repeating the argument for all i = 1, … n-1:

The worst case response time of a task occurs when it is released simultaneously with all higher-priority tasks. q.e.d.

Schedulability is checked at the critical instants.

If all tasks of a task set are schedulable at their critical instants, they are schedulable at all release times.

Observation helps designing examples

Page 17: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 17 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

The case i: pi+1 = mi pi

Lemma*: If each task period is a multiple of the period of the next higher priority task, then schedulability is also guaranteed if µ 1.

Proof: Assume schedule of Ti is given. Incorporate Ti+1:

Ti+1 fills idle times of Ti; Ti+1 completes in time, if µ 1.

Ti

Ti+1 t

T’i+1

Used as the higher priority task at the next iteration.

* wrong in the book of 2003

Page 18: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 18 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Proof of the RM theorem

Let T={T1, T2} with p1 < p2.

Assume RM is not used prio(T2) is highest:

T1

T2 t

Schedule is feasible if c1+c2 ≦ p1 (1)Schedule is feasible if c1+c2 ≦ p1 (1)

c1

c2

p1

Define F= p2/p1: # of periods of T1 fully contained in T2Define F= p2/p1: # of periods of T1 fully contained in T2

Morein-depth:

Page 19: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 19 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Case 1: c1 p2 – Fp1

Assume RM is used prio(T1) is highest:

T1

T2 t

Case 1*: c1 p2 – F p1

(c1 small enough to be finished before 2nd instance of T2)

Case 1*: c1 p2 – F p1

(c1 small enough to be finished before 2nd instance of T2)

p2Fp1

Schedulable if (F +1) c1 + c2 p2 (2)Schedulable if (F +1) c1 + c2 p2 (2)

* Typos in [Buttazzo 2002]: < and mixed up]

Page 20: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 20 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Proof of the RM theorem (3)

Not RM: schedule is feasible if c1+c2 p1 (1)

RM: schedulable if (F+1)c1 + c2 p2 (2)

From (1): Fc1+Fc2 Fp1

Since F 1: Fc1+c2 Fc1+Fc2 Fp1

Adding c1: (F+1) c1+c2 Fp1 +c1

Since c1 p2 – Fp1: (F+1) c1+c2 Fp1 +c1 p2

Hence: if (1) holds, (2) holds as well

For case 1: Given tasks T1 and T2 with p1 < p2, then if the schedule is feasible by an arbitrary (but fixed) priority assignment, it is also feasible by RM.

Page 21: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 21 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Case 2: c1 > p2 – Fp1

Case 2: c1 > p2 – Fp1

(c1 large enough not to finish before 2nd instance of T2)

T1

T2 tp2Fp1

Schedulable if F c1 + c2 F p1 (3)

c1+c2 p1 (1)

Multiplying (1) by F yields F c1+ F c2 F p1

Since F 1: F c1+ c2 F c1+ Fc2 F p1

Same statement as for case 1.

Page 22: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 22 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Calculation of the least upper utilization bound

Let T={T1, T2} with p1 < p2.

Proof procedure: compute least upper bound Ulup as follows

Assign priorities according to RM

Compute upper bound Uup by setting computation times to fully utilize processor

Minimize upper bound with respect to other task parameters

As before: F= p2/p1

c2 adjusted to fully utilize processor.

Page 23: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 23 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Case 1: c1 p2 – Fp1

Largest possible value of c2 is c2= p2 – c1 (F+1)Corresponding upper bound is

T1

T2 tp2Fp1

)1(11

11

1

2

2

1

2

1

1

1

2

12

1

1

2

2

1

1 Fp

p

p

c

p

F c

p

c

p

F – cp

p

c

p

c

p

cUub

)(

)(

{ } is <0 Uub monotonically decreasing in c1

Minimum occurs for c1 = p2 – Fp1

Page 24: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 24 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Case 2: c1 p2 – Fp1

Largest possible value of c2 is c2= (p1-c1)FCorresponding upper bound is:

T1

T2 tp2Fp1

Fp

p

p

cF

p

pF

p

c

p

cF

p

p

p

F – cp

p

c

p

c

p

cUub

1

2

2

1

2

1

2

1

1

1

2

1

2

11

1

1

2

2

1

1 )(

{ } is 0 Uub monotonically increasing in c1 (independent of c1 if {}=0)

Minimum occurs for c1 = p2 – Fp1, as before.

Page 25: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 25 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Utilization as a function of G=p2/p1-F

For minimum value of c1:

F

p

pF

p

pF

p

pF

p

p

p

FppF

p

pF

p

p

p

cF

p

pUub

1

2

1

2

2

1

1

2

2

12

2

1

1

2

2

1

2

1

Let ;1

2 Fp

pG

GF

GG

GF

GGGF

GF

GF

FFpp

GF

pp

GFGF

p

pUub

11

)(

//

22

12

2

12

22

2

1

Since 0 G< 1: G(1-G) 0 Uub increasing in F

Minimum of Uub for min(F): F=1

G

GUub

1

1 2

Page 26: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 26 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Proving the RM theorem for n=2

This proves the RM theorem for the special case of n=2

83.0)11222

224

121

121

:10

;21;21

0)1(

12

)1(

)1()1(2

:1

1

2

2

21

2

2

2

2

2

2

1

2(2)()(

)(

since ,only gConsiderin

of minimum find to derivative Using

lub

ub

ub

ub

U

GG

GG

G

GG

G

GGG

dG

dU

UG

GU

end

Page 27: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 27 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Properties of RM scheduling

RM scheduling is based on static priorities. This allows RM scheduling to be used in an OS with static priorities, such as Windows NT.

No idle capacity is needed if i: pi+1=F pi: i.e. if the period of each task is a multiple of the period of the next higher priority task, schedulability is then also guaranteed if µ 1.

A huge number of variations of RM scheduling exists.

In the context of RM scheduling, many formal proofs exist.

Page 28: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 28 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

EDF

EDF can also be applied to periodic scheduling.

EDF optimal for every hyper-period(= least common multiple of all periods)

Optimal for periodic scheduling

EDF must be able to schedule the example in which RMS failed.

Page 29: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 29 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Comparison EDF/RMS

T2 not preempted, due to its earlier deadline.

EDF-animation

RMS:

EDF:

Page 30: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 30 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

EDF: Properties

EDF requires dynamic priorities

EDF cannot be used with an operating system just providing static priorities.

However, a recent paper (by Margull and Slomka) at DATE 2008 demonstrates how an OS with static priorities can be extended with a plug-in providing EDF scheduling(key idea: delay tasks becoming ready if they shouldn’t be executed under EDF scheduling.

Page 31: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 31 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Comparison RMS/EDF

RMS EDF

Priorities Static Dynamic

Works with OS with fixed priorities

Yes No*

Uses full computational power of processor

No,just up till µ=n(21/n-1)

Yes

Possible to exploit full computational power of processor without provisioning for slack

No Yes

* Unless the plug-in by Slomka et al. is added.

Page 32: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 32 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Sporadic tasks

If sporadic tasks were connected to interrupts, the execution

time of other tasks would become very unpredictable.

Introduction of a sporadic task server,periodically checking for ready sporadic tasks;

Sporadic tasks are essentially turned into periodic tasks.

Page 33: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 33 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Dependent tasks

The problem of deciding whether or not a schedule existsfor a set of dependent tasks and a given deadlineis NP-complete in general [Garey/Johnson].

Strategies:

1. Add resources, so that scheduling becomes easier

2. Split problem into static and dynamic part so that only a minimum of decisions need to be taken at run-time.

3. Use scheduling algorithms from high-level synthesis

Page 34: Fakultät für informatik informatik 12 technische universität dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund,

- 34 -technische universitätdortmund

fakultät für informatik

p. marwedel, informatik 12, 2010

Summary

Periodic scheduling

Rate monotonic scheduling

EDF

Dependent and sporadic tasks (briefly)