Sandtids systemer 2.modul
-
Upload
elaine-key -
Category
Documents
-
view
45 -
download
0
description
Transcript of Sandtids systemer 2.modul
![Page 1: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/1.jpg)
Sandtids systemer 2.modul
el.
Henriks 1. forsøg m. Power Point
![Page 2: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/2.jpg)
Real Time Systems
• Specifications -> Task Set
• Task Specifications
• Scheduling
• Fixed Priority Scheduling
• Dependent tasks
• Dynamic Priority Scheduling
• Aperiodic Tasks
![Page 3: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/3.jpg)
Task Specifications
• A task is a collection of jobs J1,J2,J3,…
• A job is a set of instructions to be executed
• A job is specified in time by: a ready time r, a computation time c and a deadline d
![Page 4: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/4.jpg)
The job life cycle
Time
Running
Completed C
Scheduled S
Ready r
Computation time c Deadline d
Pre-emptied
![Page 5: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/5.jpg)
Task Specifications
• Periodic tasks
• Aperiodic tasks
• Sporadic tasks
• Hard Real Time
• Real Time
• Soft Real Time
• Non Real Time
![Page 6: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/6.jpg)
Task Specifications
r1Time
r4
T
r2
T T T
Periodic Task
r3
![Page 7: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/7.jpg)
Task Specifications
r1Time
r4r2
Aperiodic Task
r3
T3
0 < Ti, 0 < c << T , (Ti < c)
T1 T2
![Page 8: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/8.jpg)
Task Specifications
r1Time
r4r2
Sporadic Task
r3
T3
0 < c << Tmin < Ti
T1 T2
![Page 9: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/9.jpg)
Task Specifications
• Hard Real Time: d <= Tmin (T), (periodic,sporadic)
• Real Time: d > Tmin (T), (periodic, sporadic)
• Soft Real Time: C < d (periodic,aperiodic)
• Non Real Time
![Page 10: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/10.jpg)
Scheduling
• For periodic and sporadic tasks: {Ti, ci}, ci / Ti = U < 1 (stable),
(U>1, unstable)
• For aperiodic tasks: ri = ci / Ti, U= ri < 1
![Page 11: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/11.jpg)
Scheduling
• Pre emptive• Non Pre emptive
• Fixed Schedules• Cyclic Schedules• Round Robin• Fixed Priorities• Rate/Deadline
Monotonic• Dynamic Priorities• Earliest Deadline First
![Page 12: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/12.jpg)
Fixed Schedules
• Ready times need to be known a priori
• Only very light run time load
• Table based
• Less flexible
• Cyclic schedules are fixed schedules
![Page 13: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/13.jpg)
Cyclic Schedules
• All periods are multiples of dT
• LCM: is the Least Common Multiple
• Schedule is made for [0, dt * LCM]
• If CPU is idle at dT * LCM the schedule may be reused in subsequent intervals.
• Applicable both for Pre emptive and Non Pre Emptive Schedules
![Page 14: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/14.jpg)
Cyclic Schedules (example)
• T1=2,c1=1,d1=2
• T2=3,c2=3/2,d2=3
Task
Time
1 2 3 4 5 6
![Page 15: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/15.jpg)
Round Robin
• Time line divided into slots dT• Tasks are granted execution time cyclically.• When a job has executed for dT or is
completed CPU access is passed on.• Non pre emptive if dT is infinite.• Critical instant when grant is just passed on
when job is ready along with jobs from all other tasks
![Page 16: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/16.jpg)
Round Robin (example)
• T1=2,c1=1,d1=2
• T2=3,c2=3/2,d2=3, dT=1/2
1 2 3
Task
Time
Task
Time 1 2
Test for task 2 Test for task 1
![Page 17: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/17.jpg)
Fixed Priorities
• Tasks are assigned priorities in order
• A task is ready if its latest job is still not completed
• A task is running if it is ready and it has highest priority among ready tasks.
• Both pre emptive and non preemptive
![Page 18: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/18.jpg)
Fixed priorities (example)
• T1=2,c1=1,d1=2
• T2=3,c2=3/2,d2=3 , preemptive
Task
Time
1 2 3 4 5 6
Task 2 missed deadline
![Page 19: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/19.jpg)
Fixed priorities (properties)
• Flexible
• Medium run time demands
• Not optimal
• Typically better then Round Robin
• Well known schedulability criteria
![Page 20: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/20.jpg)
Fixed Priorities (schedulability)
• Critical Instant Theorem (Liu,Layland) Worst case completion time is when launced along with jobs from all other tasks simultaneously.
• Utilization U < N (2N-1) -> 0.7 < 1 !!• Completion time:
exist t <= di : t => i[t / Tj] cj + ci
![Page 21: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/21.jpg)
Fixed Priorities (example)• T1=2,c1=1,d1=2
• T2=3,c2=3/2,d2=3 , preemptive
c2=3/2
c1=1
T1=2
C2=3½ > d2=3 1 2 3
Time
Work
![Page 22: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/22.jpg)
Priority Order
• Priorities according to importance or time efficiency.
• DMA: d1 < d2 < d3 < .. < dN
• DMA (Deadline Monotonic) / RMA (Rate Monotonic) is optimal when d<=T / d=T
• No general optimal order when d>T
![Page 23: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/23.jpg)
Dependent tasks
• Inter Process Communication (IPC)
• Critical regions
• Producer Consumer
• Rendezvous
• All introduce dependence
![Page 24: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/24.jpg)
Critical regions (example)
2
3Time
Running
W(S)
W(S)
1
S(S)
Priority inversion
W(S)
![Page 25: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/25.jpg)
Priority Ceiling
• Priority ceil C(S) of semaphore S is the highest (minimum) priority of all tasks locking S
• Runtime:– if prio < min {C(Si)| Si locked} when attempting a
lock on S then lock and active. – else suspend. Task locking S inherits prio (if lower)
until unlock.
• Whenever a semaphore is unlocked the suspend queue is inspected to see if any task may be resumed.
![Page 26: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/26.jpg)
Priority Ceiling (assumptions and properties)
• Assumption: Critical regions nicely nested.
• Property: No deadlocks possible
• Property: No task is blocked by lower priority tasks for more than the duration of 1 critical region.
![Page 27: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/27.jpg)
Critical regions with PC (example)
2
3Time
Running
W(S)
W(S), suspended
1
3 -> prio(1)
W(S)
S(S), 3 -> low prio.
![Page 28: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/28.jpg)
Fixed Priorities with PC (schedulability)
• Completion time: exist t <= di : t => i[t / Tj] cj + ci + Bi
• Bi is the duration of the longest critical region possibly blocking taui
• Lower priority tasks also block through priority inheritance
![Page 29: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/29.jpg)
Dynamic priority scheduling
• At every scheduling point considers states of every job.
• Heavy run time load.
• Includes fixed schedules and fixed priorities as special cases – thus stronger
• Earliest Deadline First (EDF) and Least Laxity First (LLF) are special cases.
![Page 30: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/30.jpg)
Ealiest Deadline First (EDF)
• At every scheduling point runs job with closest deadline.
• Optimal among all schedules.
• U < 1 sufficient for d=T
• No priority according to importance possible.
![Page 31: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/31.jpg)
EDF (example)
• T1=2,c1=1,d1=2
• T2=3,c2=3/2,d2=3
Task
Time
1 2 3 4 5 6
d1,1 d2,1 d1,2 d2,2 d1,3
RMA/DMA missed deadline
![Page 32: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/32.jpg)
Aperiodic tasks
• Low (close to zero) minimum interarrival time Tmin
• May be seen from probabilistic and worst case viewpoints
• Probabilistic viewpoint uses mean inter arrival times T and queueing theory.
• Worst case view uses Tmin. OK if c/Tmin < available CPU fraction.
• Aperiodic server or background task
![Page 33: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/33.jpg)
Probabilistic viewpoint (queueing)
• Assumes Poisson arrivals and exponential distributed service times. (Approximation.)
• l=1/T : arrival rate, u: service rate.
• Load (utilization) r = l/u
• Mean queue length Q = r / (1-r)
• Mean waiting time W = Q/l = 1 / (u –l) (Littles theorem)
![Page 34: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/34.jpg)
Worst case v.p.
• Higher priority computation times Ki
• Higher priority utilization Ui
• W.C. Completion time for n jobs of taui: Cn < min{t | t > n ci + Ki + t*Ui} => Cn < (n ci + Ki) / (1-Ui)
• W.C. Waiting Wn = Cn – rn < Cn - (n-1)*Tmin < n (ci / (1-Ui) –Tmin) + Ki / (1-Ui) +Tmin = (ci +Ki ) / (1-Ui) for n=1
![Page 35: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/35.jpg)
Worst Case V.P.
1 2 3 4 5 6 n
Waiting timeKi / (1- Ui) + Tmin
1
Ci/(1-Ui) - Tmin
(ci + Ki) / (1- Ui)
![Page 36: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/36.jpg)
Sporadic Tasks
• Tmin >> c• Typically hard real time (alarm not.) d << Tmin• No queueing.• If aperiodic server T < d << Tmin (high load)• Sporadic server accesible at all times, however
allways Tmin between every use.• Ticket issued at start up time. New ticket at
n*Tmin if used – else old ticket left.• High responsiveness – low load.
![Page 37: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/37.jpg)
Sporadic Server (example)
Time
Tickets
r1
Tmin
1
r2 r4 r3
![Page 38: Sandtids systemer 2.modul](https://reader036.fdocuments.in/reader036/viewer/2022062301/568135ef550346895d9d6061/html5/thumbnails/38.jpg)
The End