Top Banner
Technische Universität Dortmund Classical scheduling algorithms for periodic systems Peter Marwedel TU Dortmund, Informatik 12 Germany 2007/12/14
33

Classical scheduling algorithms for periodic systems

Feb 25, 2016

Download

Documents

Tryna

Classical scheduling algorithms for periodic systems. Peter Marwedel TU Dortmund, Informatik 12 Germany. 2007/12/14. Structure of this course. guest lecture on multisensor systems (Fink). New clustering. 3: Embedded System HW. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Classical scheduling algorithms for periodic systems

Technische Universität Dortmund

Classical scheduling algorithmsfor periodic systems

Peter MarwedelTU Dortmund, Informatik 12

Germany

2007/12/14

Page 2: Classical scheduling algorithms for periodic systems

- 2 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Structure of this course

New clustering

2: Specifications

3: Embedded System HW

4: Standard Software, Real-Time Operating Systems

5: Scheduling,HW/SW-Partitioning, Applications to MP-Mapping

6: Evaluation

8: Testing

7: Optimization of Embedded Systems

App

licat

ion

Kno

wle

dge

guest lecture on multisensor systems (Fink)

guest lecture on (RT-) OS (Spinczyk)

guest lecture from industry (NXP)[Digression: Standard Optimization

Techniques (1 Lecture)]

Page 3: Classical scheduling algorithms for periodic systems

- 3 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Classes of mapping algorithmsconsidered in this course

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

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

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

Design space exploration using genetic algorithmsHeterogeneous systems, incl. communication modeling

Page 4: Classical scheduling algorithms for periodic systems

- 4 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

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: Classical scheduling algorithms for periodic systems

- 5 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Periodic scheduling

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 a job of

Ti becoming available and the time until the same job Ti has to finish execution.

• ℓi be the laxity or slack, defined as ℓi = di - ci

pi

di

ci ℓi

Page 6: Classical scheduling algorithms for periodic systems

- 6 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Accumulated utilization

Accumulated utilization:

n

i i

i

pc

1

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

m

Page 7: Classical scheduling algorithms for periodic systems

- 7 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

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 accumulated utilization µ:

)12( /1

1

nn

i i

i npc

Page 8: Classical scheduling algorithms for periodic systems

- 8 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

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: Classical scheduling algorithms for periodic systems

- 9 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

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

npc

Page 10: Classical scheduling algorithms for periodic systems

- 10 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Example of RM-generated schedule

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

Page 11: Classical scheduling algorithms for periodic systems

- 11 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

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

Page 12: Classical scheduling algorithms for periodic systems

- 12 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

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

leviRTS animation

Page 13: Classical scheduling algorithms for periodic systems

- 13 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Proof of RM optimality

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.

Morein-depth:

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

Page 14: Classical scheduling algorithms for periodic systems

- 14 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Critical instances (1)

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

cn+2ci

Tn

Tit

Maximum delay achieved if Tn and Ti start simultaneously.

cn+3ci

Tn

Tit

Delay may increase if Ti starts earlier

Page 15: Classical scheduling algorithms for periodic systems

- 15 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Critical instances (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.

Page 16: Classical scheduling algorithms for periodic systems

- 16 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

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

Page 17: Classical scheduling algorithms for periodic systems

- 17 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

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)

c1

c2

p1

Define F= p2/p1: # of periods of T1fully contained in T2

Page 18: Classical scheduling algorithms for periodic systems

- 18 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Case 1: c1 p2 – Fp1

Assume RM is used prio(T1) is highest:

T1

T2 t

Case 1*: c1 p2 – Fp1

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

p2Fp1

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

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

Page 19: Classical scheduling algorithms for periodic systems

- 19 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

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 20: Classical scheduling algorithms for periodic systems

- 20 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

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 21: Classical scheduling algorithms for periodic systems

- 21 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

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 22: Classical scheduling algorithms for periodic systems

- 22 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Case 1: c1 p2 – Fp1

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

T1

T2 tp2Fp1

)1(1)1( 1)1( 1

2

2

1

2

1

1

1

2

12

1

1

2

2

1

1 Fpp

pc

pF c

pc

pF – cp

pc

pc

pcUub

{ } is <0 Uub monotonically decreasing in c1

Minimum occurs for c1 = p2 – Fp1

Page 23: Classical scheduling algorithms for periodic systems

- 23 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Case 2: c1 p2 – Fp1

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

T1

T2 tp2Fp1

Fpp

p cF

ppF

p c

pcF

pp

p F – cp

pc

pc

pcUub

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 24: Classical scheduling algorithms for periodic systems

- 24 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

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

For minimum value of c1:

F

ppF

ppF

ppF

pp

pFppF

ppF

pp

pcF

ppUub

1

2

1

2

2

1

1

2

2

12

2

1

1

2

2

1

2

1

; Let1

2 FppG

GFGG

GFGGGF

GFGF

FFppGF

ppGFGF

ppUub

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

GGUub

11 2

Page 25: Classical scheduling algorithms for periodic systems

- 25 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Proving the RM theorem for n=2

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

83.0)12(2)12(22

224)12(1)12(1

:10 since ,only gConsiderin ;21 ;21

0)1(

12)1(

)1()1(2

: of minimum find to derivative Using11

212

2

21

2

2

2

2

2

lub

ub

ub

ub

U

GGGG

GGG

GGGG

dGdU

UGGU

end

Page 26: Classical scheduling algorithms for periodic systems

- 26 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Properties of RM scheduling

RM scheduling is based on static priorities. This allows RM scheduling to be used in standard OS, 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 27: Classical scheduling algorithms for periodic systems

- 27 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

EDF

EDF can also be applied to periodic scheduling.

EDF optimal for every period

Optimal for periodic scheduling

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

Page 28: Classical scheduling algorithms for periodic systems

- 28 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Comparison EDF/RMS

RMS:

EDF:

T2 not preempted, due to its earlier deadline.

EDF-animation

Page 29: Classical scheduling algorithms for periodic systems

- 29 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

EDF: Properties

EDF requires dynamic priorities

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

Page 30: Classical scheduling algorithms for periodic systems

- 30 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Comparison RMS/EDF

RMS EDF

Priorities Static Dynamic

Works with std. 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

Page 31: Classical scheduling algorithms for periodic systems

- 31 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

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 32: Classical scheduling algorithms for periodic systems

- 32 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

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 33: Classical scheduling algorithms for periodic systems

- 33 - P. Marwedel, TU Dortmund, Informatik 12, 2007

TU Dortmund

Summary

Periodic scheduling Rate monotonic scheduling

• Proof of the utilization bound for n=2.

EDF

Dependent and sporadic tasks (briefly)