real-time scheduling cs 3204 – operating systems lecture 20 3/3/2006 shahrooz feizabadi
TRANSCRIPT
Real-Time SchedulingCS 3204 – Operating Systems
Lecture 20
3/3/2006
Shahrooz Feizabadi
CS3204 Spring 2006 3/3/06 2
Real-Time SystemsSystems that must service requests within a precise time constraint:
Air traffic control systems Railway switching systems Industrial automation Robotics Military
Generally, systems that must respond to external physical phenomena.
CS3204 Spring 2006 3/3/06 3
Tracking System Example
Dynamic trajectory calculations False alarms Verification System response Real-time clock 687m error!
CS3204 Spring 2006 3/3/06 4
System Resources
Different approaches to resource management: General-purpose OS
Extensible time horizon: all tasks eventually finish Similarly, elastic memory: demand paging Fairness Non-starvation
Real-Time system Fixed resources Tasks adjusted accordingly Predictability
CS3204 Spring 2006 3/3/06 5
Schedulers
Preemptive / non-preemptive Static / dynamic On-line / off-line Optimal / heuristic Clairvoyance
CS3204 Spring 2006 3/3/06 6
Real-Time Task Parameters
Ci
ai disi fi
t
Arrivaltime
Computationtime
starttime
finishtime
deadline
CS3204 Spring 2006 3/3/06 7
Real-Time Tasks
Ci
ai disi fi
t
Ci
ai disi fi
t
Laxity (slack)
Deadline miss
x
CS3204 Spring 2006 3/3/06 8
RMA Rate Monotonic Algorithm Static Preemptive Fixed-priority assignment Periodic tasks Guarantee-based Hard real-time correctness – all
deadlines always met
CS3204 Spring 2006 3/3/06 9
RMA (continued)
RMA: Assign unique priorities, in descending order, to tasks ordered by ascending periods: the shorter the period, the higher the priority.
CS3204 Spring 2006 3/3/06 10
RMA – Example
Task T C P
A 5 1
B
C
A
50 10 15 20 25
Assume deadline equals period (T).
CS3204 Spring 2006 3/3/06 11
RMA – Example
Task T C P
A 5 1
B 9 3
C
A
50 10 15 20 25
B
CS3204 Spring 2006 3/3/06 12
RMA – Example
Task T C P
A 5 1
B 9 3
C 12 2
A
50 10 15 20 25
B
C
CS3204 Spring 2006 3/3/06 13
RMA – Example
Task T C P
A 5 1 3
B 9 3 2
C 12 2 1
A
50 10 15 20 25
B
C
CS3204 Spring 2006 3/3/06 14
RMA – Example
Task T C P
A 5 1 3
B 9 3 2
C 12 2 1
A
50 10 15 20 25
B
C
CS3204 Spring 2006 3/3/06 15
RMA – Example
Task T C P
A 5 1 3
B 9 3 2
C 12 2 1
A
50 10 15 20 25
B
C
CS3204 Spring 2006 3/3/06 16
RMA – Example
Task T C P
A 5 1 3
B 9 3 2
C 12 2 1
A
50 10 15 20 25
B
C
CS3204 Spring 2006 3/3/06 17
RMA – Example
Task T C P
A 5 1 3
B 9 3 2
C 12 2 1
A
50 10 15 20 25
B
C
A preempts C
CS3204 Spring 2006 3/3/06 18
RMA – Example
Task T C P
A 5 1 3
B 9 3 2
C 12 2 1
A
50 10 15 20 25
B
C
CS3204 Spring 2006 3/3/06 19
RMA – Example
Task T C P
A 5 1 3
B 9 3 2
C 12 2 1
A
50 10 15 20 25
B
C
CS3204 Spring 2006 3/3/06 20
RMA – Example
Task T C P
A 5 1 3
B 9 3 2
C 12 2 1
A
50 10 15 20 25
B
C
A preempts B
CS3204 Spring 2006 3/3/06 21
RMA – Example
Task T C P
A 5 1 3
B 9 3 2
C 12 2 1
A
50 10 15 20 25
B
C
C arrives
CS3204 Spring 2006 3/3/06 22
RMA – Example
Task T C P
A 5 1 3
B 9 3 2
C 12 2 1
A
50 10 15 20 25
B
C
CS3204 Spring 2006 3/3/06 23
RMA – Example
Task T C P
A 5 1 3
B 9 3 2
C 12 2 1
A
50 10 15 20 25
B
C
CS3204 Spring 2006 3/3/06 24
RMA – Example
Task T C P
A 5 1 3
B 9 3 2
C 12 2 1
A
50 10 15 20 25
B
C
CS3204 Spring 2006 3/3/06 25
RMA (continued)
How far can we push this? Constraints
Number of tasks? Periods? Computational times?
CS3204 Spring 2006 3/3/06 26
Processor Utilization FactorFraction of CPU time spent in execution of tasks:
Otherwise stated: sum of the individual relative load contribution of each task in the task-set.
Provides an indication of system-wide computational load.
CS3204 Spring 2006 3/3/06 27
Feasibility Test
RMA guarantee: No deadlines will be missed under rate monotonic scheduling if the following condition holds:
CS3204 Spring 2006 3/3/06 28
Feasibility Test (continued)
Note that:
That is, any task-set with a CPU utilization factor of 69% or less is schedulable under RMA
Sufficient, but not necessary condition
CS3204 Spring 2006 3/3/06 29
Optimality
RMA is an optimal fixed-priority assignment algorithm: no other fixed-priority algorithms can schedule a task set that cannot be scheduled under RMA.
CS3204 Spring 2006 3/3/06 30
EDF
Earliest Deadline First Earlier the deadline, higher the priority. Dynamic assignment On-line No periodicity assumptions – can
schedule aperiodic tasks.
CS3204 Spring 2006 3/3/06 31
EDF – Example
Task T C
A 4 1
B 8 4
C 12 3
50 10 15 20 25
Assume deadline equals period (T).
A
B
C
Hyper-period
CS3204 Spring 2006 3/3/06 32
EDF – Example
Task T C
A 4 1
B 8 4
C 12 3
50 10 15 20 25
Assume deadline equals period (T).
A
B
C
CS3204 Spring 2006 3/3/06 33
EDF – Example
Task T C
A 4 1
B 8 4
C 12 3
50 10 15 20 25
Assume deadline equals period (T).
A
B
C
CS3204 Spring 2006 3/3/06 34
EDF – Example
Task T C
A 4 1
B 8 4
C 12 3
50 10 15 20 25
Assume deadline equals period (T).
A
B
C
Lexical order tie breaker
CS3204 Spring 2006 3/3/06 35
EDF – Example
Task T C
A 4 1
B 8 4
C 12 3
50 10 15 20 25
Assume deadline equals period (T).
A
B
C
CS3204 Spring 2006 3/3/06 36
EDF – Example
Task T C
A 4 1
B 8 4
C 12 3
50 10 15 20 25
Assume deadline equals period (T).
A
B
C
CS3204 Spring 2006 3/3/06 37
EDF – Example
Task T C
A 4 1
B 8 4
C 12 3
50 10 15 20 25
Assume deadline equals period (T).
A
B
C
CS3204 Spring 2006 3/3/06 38
EDF – Example
Task T C
A 4 1
B 8 4
C 12 3
50 10 15 20 25
Assume deadline equals period (T).
A
B
C
Patternrepeats
CS3204 Spring 2006 3/3/06 39
EDF Properties
Feasibility test:
U = 100% in example Bound theoretical Sufficient and necessary Optimal
CS3204 Spring 2006 3/3/06 40
Overload
Hard real-time No deadlines misses. Dimension system to meet exact timing
requirements. Soft real-time
May encounter transient or sustained overload. Design algorithm to achieve desired temporal
behavior.
CS3204 Spring 2006 3/3/06 41
Real-Time Overload Scheduling
Runtime uncertainty Dynamic system Aggregate demand exceeds capacity Fixed available bandwidth Must shed load Starvation Who survives?
CS3204 Spring 2006 3/3/06 42
EDF Domino Effect
X
X
X
Cascading deadline misses
Deadline sole scheduling parameter
CS3204 Spring 2006 3/3/06 43
Load Shedding
Feasible schedule if any task excluded in example?
Selection criteria Fitness metric Second dimension: utility
CS3204 Spring 2006 3/3/06 44
Load Shedding
X
X
X
Overload detected
CS3204 Spring 2006 3/3/06 45
Load Shedding
X
X
X
Least valuable task
u = 3
u = 1
u = 5
u = 7
Two scheduling parameters: deadline and utility
CS3204 Spring 2006 3/3/06 46
Load Shedding
X
Least valuable task
u = 3
u = 1
u = 5
u = 7