courseware Scheduling Uniprocessor Real Time Systems Jan Madsen

  • Slides: 28
Download presentation
courseware Scheduling Uniprocessor Real -Time Systems Jan Madsen Informatics and Mathematical Modelling Technical University

courseware Scheduling Uniprocessor Real -Time Systems Jan Madsen Informatics and Mathematical Modelling Technical University of Denmark Richard Petersens Plads, Building 321 DK 2800 Lyngby, Denmark Jan@imm. dtu. dk

Rate-monotonic scheduling § Real-time scheduling with provable properties [Liu and Layland 73] § Each

Rate-monotonic scheduling § Real-time scheduling with provable properties [Liu and Layland 73] § Each process is independent and given a unique priority § A process may be preempted by a higher-priority process § All processes have a deadline equal to their period and a fixed WCET § Context switching overhead is ignored So. C-MOBINET courseware Jan Madsen 2

RMS pi ai si ci pi di = T i The critical instance for

RMS pi ai si ci pi di = T i The critical instance for a process occurs when the process and all higher-priority processes are released simultaneously Must guarantee that all processes meet their deadlines, independent of order of releases So. C-MOBINET courseware Jan Madsen 3

RMS example Ti Ci p 1 50 12 p 2 40 10 p 3

RMS example Ti Ci p 1 50 12 p 2 40 10 p 3 30 10 50 p 1 40 p 2 30 p 3 0 10 So. C-MOBINET courseware 20 Jan Madsen 30 40 50 60 4

Rate-monotonic priority assignment § Each process is given a unique priority where 1 is

Rate-monotonic priority assignment § Each process is given a unique priority where 1 is the highest § Prioritize according to Ti’s, with shortest-period process given highest priority § Fixed-priority scheme § Independent of ci’s § This priority assignment is optimal No fixed priority scheme does it better! So. C-MOBINET courseware Jan Madsen 5

RMS example (cont. ) So. C-MOBINET courseware Ti Ci priority p 1 50 12

RMS example (cont. ) So. C-MOBINET courseware Ti Ci priority p 1 50 12 3 p 2 40 10 2 p 3 30 10 1 Jan Madsen 6

CPU utilization under RMS § Given N independent processes, utilization U N ci U

CPU utilization under RMS § Given N independent processes, utilization U N ci U =å i =1 Ti • Least upper bound for utilization U < N(21 N - 1) 1 N lim ( N ( 2 ®¥ N So. C-MOBINET courseware - 1) = 69. 3% Jan Madsen 7

RMS example (cont. ) Ti Ci priority U p 1 50 12 1 0.

RMS example (cont. ) Ti Ci priority U p 1 50 12 1 0. 24 p 2 40 10 2 0. 25 p 3 30 10 3 0. 33 0. 82 13 < ( U 3 2 - 1) = 0. 78 So. C-MOBINET courseware Jan Madsen 8

RMS example (cont. ) 50 p 1 40 p 2 30 p 3 0

RMS example (cont. ) 50 p 1 40 p 2 30 p 3 0 10 So. C-MOBINET courseware 20 Jan Madsen 30 40 50 60 9

RMS § The utilization-based schedulability test is sufficient but not necessary § If the

RMS § The utilization-based schedulability test is sufficient but not necessary § If the test is passed it is schedulable § If the test is not passed, it may be schedulable § If all processes meet their first deadline then they will meet all future one So. C-MOBINET courseware Jan Madsen 10

Response time analysis § Highest-priority process r=c § Other processes will suffer interference from

Response time analysis § Highest-priority process r=c § Other processes will suffer interference from higher-priority processes ri = c i + i i § Maximum interference occur at a critical instance So. C-MOBINET courseware Jan Madsen 11

Response time analysis number of releases of process pj during [0, Ri ) é

Response time analysis number of releases of process pj during [0, Ri ) é Riù Ri = ci + å ê ú cj T j Î hp (i ) ê jú each release will impose an interference of cj Processes with higher-priority than pi n é ù w n +1 wi = ci+ Îå ê iú cj j hp( i ) ê ê Tj úú So. C-MOBINET courseware Jan Madsen 12

Response time analysis example w 10 w 20 =3 R 1=3 =3 w 2

Response time analysis example w 10 w 20 =3 R 1=3 =3 w 2 éê 3 ùú 3+ 3=6 êê 7 úú w 2 éê 6 ùú 3+ 3=6 êê 7 úú 1 = 2 = So. C-MOBINET courseware Jan Madsen Ti Ci priority p 1 7 3 1 p 2 12 3 2 p 3 20 5 3 R 2=6 13

Earliest-Deadline-First Scheduling § Dynamic priority scheme § changes priorities during execution based on initiation

Earliest-Deadline-First Scheduling § Dynamic priority scheme § changes priorities during execution based on initiation times § can achieve higher CPU utilization than RMS, i. e. 100% § Priority policy: § process with closest deadline gets highest-priority So. C-MOBINET courseware Jan Madsen 14

EDF example p 1 p 2 p 3 Ti Ci p 1 3 1

EDF example p 1 p 2 p 3 Ti Ci p 1 3 1 p 2 4 1 p 3 5 2 1 3 2 2 1 2 1 3 3 2 1 2 3 2 1 1 3 3 3 0 1 2 So. C-MOBINET courseware 3 4 5 Jan Madsen 6 7 8 9 10 12 13 14 15 16 15

RMS example Ti Ci p 1 50 12 p 2 40 10 p 3

RMS example Ti Ci p 1 50 12 p 2 40 10 p 3 30 10 50 p 1 40 p 2 30 p 3 0 10 So. C-MOBINET courseware 20 Jan Madsen 30 40 50 60 16

RMS example scheduled using EDF Ti Ci p 1 50 12 p 2 40

RMS example scheduled using EDF Ti Ci p 1 50 12 p 2 40 10 p 3 30 10 50 p 1 40 p 2 30 p 3 0 10 20 So. C-MOBINET courseware 30 40 Jan Madsen 50 60 70 80 90 100 110 17

Comparing RMS and EDF § Higher CPU utilization with EDF § Easier to ensure

Comparing RMS and EDF § Higher CPU utilization with EDF § Easier to ensure that deadlines will be satisfied with RMS § RMS easier to implement So. C-MOBINET courseware Jan Madsen 18

Overload conditions § When not all processes can meet their deadlines § EDF may

Overload conditions § When not all processes can meet their deadlines § EDF may result in domino effect § First process missing its deadline may cause all subsequent processes to miss their deadlines § Accociate value wi of importance with each process § Use Ti/wi as priority (similar to shortest-process-first) So. C-MOBINET courseware Jan Madsen 19

More realistic model assumptions § § § Shared resources Data dependencies Context switching Cache

More realistic model assumptions § § § Shared resources Data dependencies Context switching Cache effects Power reduction So. C-MOBINET courseware Jan Madsen 20

Shared resources § Scheduling processes without considering resource requirements may cause priority inversion §

Shared resources § Scheduling processes without considering resource requirements may cause priority inversion § example, p 1 highest-priority process p 1{r 1} deadlock! p 2 {r 1} So. C-MOBINET courseware Jan Madsen 21

Shared resources § When there are mutual exclusion constraints, it is impossible to find

Shared resources § When there are mutual exclusion constraints, it is impossible to find a totally on-line optimal runtime scheduler [Mok 83] § Priority ceiling protocol (PCP) § a way to bound priority inversion § blocking of processes that may cause them § temporary priority increase of process § PCP prevents deadlocks So. C-MOBINET courseware Jan Madsen 22

Data dependencies t 1 t 2 di p 1 p 3 p 2 ci

Data dependencies t 1 t 2 di p 1 p 3 p 2 ci t 1 10 p 1 2 t 2 8 p 2 1 p 3 4 p 1 p 2 p 3 So. C-MOBINET courseware Jan Madsen 23

Context switching ci di p 1 3 5 p 2 2 10 p 1

Context switching ci di p 1 3 5 p 2 2 10 p 1 p 2 0 2 4 So. C-MOBINET courseware 6 8 Jan Madsen 10 0 2 4 6 8 10 24

Cache effects cache policy: least-recently-used p 1 ci average ci p 1 2 1.

Cache effects cache policy: least-recently-used p 1 ci average ci p 1 2 1. 5 p 2 1 0. 75 p 3 1 0. 75 p 2 p 3 LRU p 1 So. C-MOBINET courseware p 2 p 1 p 3 p 2 Jan Madsen p 1 p 3 p 2 25

Cache effects cache policy: keep p 1 in cache p 1 ci average ci

Cache effects cache policy: keep p 1 in cache p 1 ci average ci p 1 2 1. 5 p 2 1 0. 75 p 3 1 0. 75 p 2 p 3 p 1 So. C-MOBINET courseware p 2 p 1 p 3 p 1 Jan Madsen p 3 p 1 p 2 p 1 p 3 p 1 26

Power reduction § Power management policy § Takes time to power-down/up § Techniques: §

Power reduction § Power management policy § Takes time to power-down/up § Techniques: § event/request based § predictive § probabilistic So. C-MOBINET courseware Jan Madsen 27

Power reduction p 1 r 1 p 2 p 3 r 1 idle p

Power reduction p 1 r 1 p 2 p 3 r 1 idle p 1 r 1 idle r 1 p 2 p 3 r 1 idle So. C-MOBINET courseware Jan Madsen 28