Вы находитесь на странице: 1из 5

Disadvantages of cyclic TDDB47 Real Time Systems Lecture 2: RM & EDF

Manual scheduler construction Cannot deal with any runtime changes


What happens if we add a task to the set?

Mikael Asplund
Real-Time Systems Laboratory Department of Computer and Information Science Linkping University, Sweden The lecture notes are partly based on lecture notes by Calin Curescu, Simin NadjmTehrani, Jrgen Hansson, Anders Trne. They also loosely follow Burns and Welling book Real-Time Systems and Programming Languages. These lecture notes should only be used for internal teaching purposes at Linkping University.
Lecture 2: RM & EDF Mikael Asplund 29 pages

Denies the advantages of concurrent programming


Which?

Lecture 2: RM & EDF Mikael Asplund

2 of 29

States of a process

Priority-based scheduling
Every task has an associated priority Run task with the highest priority At every scheduling decision moment Examples Rate Monotonic (RM) Static priority assignment Earliest Deadline First (EDF) Dynamic priority assignment And many others

Lecture 2: RM & EDF Mikael Asplund

3 of 29

Lecture 2: RM & EDF Mikael Asplund

4 of 29

Schedulability Test
Test to determine whether a feasible schedule exists

Sufficient + if test is passed, then tasks are definitely schedulable - if test is not passed, we dont know Necessary + if test is passed, we dont know - if test is not passed, tasks are definitely not schedulable Exact sufficient & necessary at the same time

Rate Monotonic (RM)

Lecture 2: RM & EDF Mikael Asplund

5 of 29

Lecture 2: RM & EDF Mikael Asplund

6 of 29

Assumption

Rate Monotonic
Each process is assigned a (unique) priority based on its period; the shorter the period, the higher the priority
Assumes the Simple task model Fixed priority scheduling Preemptive Unless stated otherwise

All tasks have their initial release at time 0

Lecture 2: RM & EDF Mikael Asplund

7 of 29

Lecture 2: RM & EDF Mikael Asplund

8 of 29

Example 1
Assume we have the following task set OBS: not scheduled yet Scheduled with RM

Example 1 (contd)

Lecture 2: RM & EDF Mikael Asplund

9 of 29

Lecture 2: RM & EDF Mikael Asplund

10 of 29

Schedulability test for RM


Sufficient, but not necessary:
N i= 1

Example 2
Taskset Period (Ti) WCET (Ci) P1 20 7 P2 50 10 P3 30 5

Ci Ti
N i= 1

N 21 / N 1

Necessary, but not sufficient:

Ci Ti

Lecture 2: RM & EDF Mikael Asplund

11 of 29

Lecture 2: RM & EDF Mikael Asplund

12 of 29

Harmonic periods
Taskset: Exact schedulability test for RM if periods are harmonic:

Example 3

i= 1

i i

C 1 T

Gantt chart:

Lecture 2: RM & EDF Mikael Asplund

13 of 29

Lecture 2: RM & EDF Mikael Asplund

14 of 29

The first time is the hardest


Theorem
If all tasks meet their first deadline, then they will meet all future ones.
Proof: paper by Liu and Layland, 1973

Exact schedulability test


The scedulability of a given taskset for RM can be decided by: Drawing a schedule Doing a response time analysis Complexity: Pseudo-polynomial time

Why?

Lecture 2: RM & EDF Mikael Asplund

15 of 29

Lecture 2: RM & EDF Mikael Asplund

16 of 29

Response time analysis


Tasks suffer interference from higher priority tasks Response time: the time that passes since the task is released and until it finishes
R i =C i +I i

Optimality of scheduling algorithms

A scheduler is optimal if it always finds a schedule when a schedulability test indicates there is one.
Burns, 1991

R i =Ci

jhp i


Ri Tj

Cj

An optimal scheduling algorithm is one that may fail to meet a deadline if no other scheduling algorithm can meet it.
Stankovic et al., 1995

Iterative formula for calculating response time

w n+ 1 =Ci i

jhp i


wn i Tj

An optimal scheduling algorithm is guaranteed to always find a feasible schedule, given that a feasible schedule does exist.
Hansson, 1998

Cj

Lecture 2: RM & EDF Mikael Asplund

17 of 29

Lecture 2: RM & EDF Mikael Asplund

18 of 29

Optimality of RM

What to do if not schedulable


Change the task set utilitsation by reducing Ci

Rate Monotonic is optimal among fixed priority schedulers

code optimisation faster processor

If we assume the Simple Process Model for the tasks Increase Ti for some process If your program and environment allows it

Lecture 2: RM & EDF Mikael Asplund

19 of 29

Lecture 2: RM & EDF Mikael Asplund

20 of 29

RM characteristics
Easy to implement. Drawback: May not give a feasible schedule even if processor is idle at some points.

Earliest Deadline First (EDF)

Lecture 2: RM & EDF Mikael Asplund

21 of 29

Lecture 2: RM & EDF Mikael Asplund

22 of 29

Earliest Deadline First (EDF)


Always runs the process that is closest to its deadline.
Dynamic priority scheduling Evaluated at run-time What are the events that should trigger a priority reevaluation? Assumes the Simple task model Actually more relaxed: Di < Ti Preemptive Unless stated otherwise

Schedulability test for EDF


Utilitsation test Necessary and sufficient Or exact test

N i= 1

Ci Ti

Lecture 2: RM & EDF Mikael Asplund

23 of 29

Lecture 2: RM & EDF Mikael Asplund

24 of 29

Optimality of EDF

Example 4

Consider following task set: WCET (Ci) EDF is optimal among dynamic priority schedulers Deadline (Di = Ti)

P1 P2 2 4 5 7

If we assume the Simple Process Model for the tasks Or a more relaxed one where Di < Ti

Is it schedulable with EDF?

Is it schedulable with RM?

Lecture 2: RM & EDF Mikael Asplund

25 of 29

Lecture 2: RM & EDF Mikael Asplund

26 of 29

Domino Effect

EDF vs. RM
EDF can handle tasksets with higher processor utilisation. Example 4 not schedulable with RMS! EDF has simpler exact analysis RMS can be implemented to run faster at run-time Depends on the OS But they usually like fixed priorities more

Lecture 2: RM & EDF Mikael Asplund

27 of 29

Lecture 2: RM & EDF Mikael Asplund

28 of 29

Reading material
Chapter 13 in Burns & Wellings Chapter 4 in Butazzo for the proofs of sufficient condition and optimality

Dynamic Scheduling

Lecture 2: RM & EDF Mikael Asplund

29 of 29

Lecture 2: RM & EDF Mikael Asplund

30 of 29

Вам также может понравиться