RTOS Session5
RTOS Session5
Purushotham BV
[email protected]
1
Clock Driven Scheduling
• 6.1 Assumptions
• 6.2 Fixed-priority v/s Dynamic-Priority Algorithms
• 6.3 Maximum Schedulable Utilization
• 6.4 Optimality Of The RM and DM Algorithms
• 6.5 A Schedulability Test for Fixed-Priority Tasks with
Short Response Times
• 6.6 Schedulability Test for Fixed-priority Tasks with
Arbitrary Response Times
• 6.7 Sufficient Schedulability Conditions for the RM and
DM Algorithms
• 6.8 Practical Factors
• 6.9 Summary
2
Dynamic v/s Static Systems
• Recall from previous lecture:
– If jobs are scheduled on multiple processors, and a job can be dispatched
to any of the processors, the system is dynamic
– If jobs are partitioned into subsystems, each subsystem bound statically
to a processor, we have a static system
– Difficult to determine the best- and worst-case performance of dynamic
systems, so most hard real-time systems built are static
• In static systems, the scheduler for each processor schedules the
jobs in its subsystem independent of the schedulers for the other
processors
Þ Results demonstrated for priority-driven uniprocessor systems
are applicable to each subsystem of a static multiprocessor
system
– They are not applicable to dynamic multiprocessor systems
3
Fixed- and Dynamic-Priority Algorithms
4
Fixed-Priority Scheduling:
Rate-Monotonic (RM)
• Best known fixed-priority algorithm is rate-monotonic
scheduling
• Assigns priorities to tasks based on their periods
– The shorter the period, the higher the priority
– The rate (of job releases) is the inverse of the period, so jobs
with higher rate have higher priority
• Widely studied and used
• For example, consider a system of 3 tasks:
– T1 = (4, 1) ⇒ rate = 1/4 = 0.25
– T2 = (5, 2) ⇒ rate = 1/5 = 0.2
– T3 = (20, 5) ⇒ rate = 1/20 = 0.05
– Total utilization is 0.9 (90%)
– Relative priorities: T1 > T2 > T3 (smaller period highest priority) 5
Example: Rate-Monotonic Scheduling
6
Fixed-Priority Scheduling: Deadline
Monotonic (DM)
• The deadline-monotonic algorithm assigns task priority
according to relative deadlines – the shorter the relative
deadline, the higher the priority
• When relative deadline of every task matches its period,
then rate monotonic and deadline-monotonic give identical
results
• When the relative deadlines are arbitrary:
– Deadline-monotonic can sometimes produce a feasible schedule in
cases where rate-monotonic cannot
– But, rate-monotonic always fails when deadline-monotonic fails
=>Deadline-monotonic
preferred to RM
1
Deadline Monotonic
• T1(50,50,25,100),
T2(0,62.5,10,20) &
T3(0,125,25,50)
• Total Utilization is 0.86
• Priority T2>T3>T1
1
Dynamic-Priority Algorithms
• Earliest deadline first (EDF)
– The job queue is ordered by earliest deadline
• Least slack time first (LST)
– The job queue is ordered by least slack time
– Two variations:
• Strict LST – scheduling decisions are made also whenever a queued
job’s slack time becomes smaller than the executing job’s slack time
– huge overheads, not used
• Non-strict LST – scheduling decisions made only when jobs release
or complete
• First in, first out (FIFO)
– Job queue is first-in-first-out by release time
• Last in, first out (LIFO)
– Job queue is last-in-first-out by release time
9
Relative Merits
• Fixed- and dynamic-priority scheduling algorithms
have different properties; neither appropriate for all
scenarios
• Algorithms that do not take into account the urgencies
of jobs in priority assignment usually perform poorly
– e.g FIFO, LIFO
• The EDF algorithm gives higher priority to jobs that
have missed their deadlines than to jobs whose
deadline is still in the future
– Not necessarily suited to systems where occasional overload
unavoidable
10
Relative Merits (Contd.,)
• Dynamic algorithms like EDF can produce feasible
schedules in cases where RM and DM cannot
– But fixed priority algorithms often more predictable ( refer
text : pg 122-123 : Figure6-5 )
11
Example: Comparing Different Algorithms
12
Ex: RM, EDF, LST and FIFO
13
Schedulability Tests
14
Scheduable Utilization
15
Scheduable Utilization: EDF
16
Schedulable Utilization: EDF (Contd.,)
17
Schedulable Utilization: EDF (Contd.,)
18
Schedulable Utilization: RM
19
Schedulable Utilization : RM (Contd.,)
20
Schedulable Utilization: RM (Contd.,)
21
Optimality of RM and DM Algorithms
23
Schedulability of Fixed-Priority Tasks
• We have identified several simple schedulability tests
for fixed priority scheduling:
– A system of n independent preemptable periodic tasks with
Di = pi can be feasibly scheduled on one processor using
RM if and only if U ≤ n⋅(21/n – 1)
– A system of simply periodic independent preemptable tasks
with Di ≥ pi is schedulable on one processor using the RM
algorithm if and only if U ≤ 1
– [similar results for DM]
• But: there are algorithms and regions of operation
where we don’t have a schedulability test and must
resort to exhaustive simulation
– Is there a more general schedulability test? Yes, but not as
simple as those we’ve seen so far…
24
Schedulability Test for Fixed-Priority Tasks
w1(8) = 3, W1 = 3 ≤ 8, ∴ T1 is schedulable
• For RM, shortest period is highest priority
W2 = 6 ≤ 9, ∴ T2 is schedulable
w2(8) = 3 + ⌈8/8⌉⋅3 = 6
W3 = 15 ≤ 15, ∴ T3 is schedulable.
w3(t) = 6 + ⌈8/8⌉⋅3 + ⌈9/8⌉⋅3 = t
27
Finding the Critical Instant (Contd.,)
28/21
Finding the Critical Instant (Contd.,)
29
Using the Critical Instant
30
2. Time-Demand Analysis
31
Time Demand Analysis (Contd.,)
32
Time Demand Analysis (Contd.,)
33
Time Demand Analysis (Contd.,)
34
Time Demand Analysis (Contd.,)
35
Time demand Analysis: Summary
36
Problem
38
Blocking and Priority Inversion
39
Self-Suspension and Context Switches
40
Tick Scheduling
41
Summary
• Have Discussed fixed-priority scheduling of periodic
tasks:
– Optimality of RM and DM
– More general schedulability test and time-demand analysis
• Outlined practical factors that affect real-world periodic
systems
42