0% found this document useful (0 votes)
28 views42 pages

RTOS Session5

The document discusses clock-driven scheduling in real-time operating systems, focusing on fixed-priority and dynamic-priority algorithms. It covers concepts such as schedulability tests, optimality of Rate-Monotonic (RM) and Deadline-Monotonic (DM) algorithms, and practical factors affecting scheduling. The summary includes comparisons of different scheduling algorithms and methods for analyzing their feasibility in periodic task systems.

Uploaded by

purushotham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views42 pages

RTOS Session5

The document discusses clock-driven scheduling in real-time operating systems, focusing on fixed-priority and dynamic-priority algorithms. It covers concepts such as schedulability tests, optimality of Rate-Monotonic (RM) and Deadline-Monotonic (DM) algorithms, and practical factors affecting scheduling. The summary includes comparisons of different scheduling algorithms and methods for analyzing their feasibility in periodic task systems.

Uploaded by

purushotham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 42

SEWP ZG524

Real - Time Operating Systems

Clock Driven Scheduling

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

• A priority-driven scheduler is an on-line scheduler


– It does not pre-compute a schedule of tasks/jobs: instead assigns
priorities to jobs when released, places them on a run queue in priority
order
– When pre-emption is allowed, a scheduling decision is made whenever a
job is released or completed
– At each scheduling decision time, the scheduler updates the run queues
and executes the job at the head of the queue
• Jobs in a task may be assigned the same priority (task level
fixed priority) or different priorities (task level dynamic-
priority)
• The priority of each job is usually fixed (job level fixed-
priority); but some systems can vary the priority of a job after it
has started (job level dynamic-priority)
– Job level dynamic-priority usually very inefficient

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

• Compare the performance of RM, EDF, LST and FIFO


scheduling
• Assume a single processor system with 2 tasks:
– T1 = (2, 1)
– T2 = (5, 2.5) H = 5
• The total utilization is 1.0 => no slack time
– Expect some of these algorithms to lead to missed
deadlines!
– This is one of the cases where EDF works better than
RM/DM

12
Ex: RM, EDF, LST and FIFO

13
Schedulability Tests

• Simulating schedules is both tedious and error-


prone… can we demonstrate correctness without
working through the schedule?

• Yes, in some cases! This is a schedulability test


– A test to demonstrate that all deadlines are met, when
scheduled using a particular algorithm
– An efficient schedulability test can be used as an on-line
acceptance test; clearly exhaustive simulation is too
expensive for this!

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

• In the general case RM and DM algorithms are not


optimal
– Some systems cannot be scheduled (URM < 1)
– Complex expressions for maximum schedulable utilization
discussed in last lecture
• However, RM and DM are optimal in simply periodic
systems
– A system of periodic tasks is simply periodic if the period of
each task is an integer multiple of the period of the other
tasks: pk = n⋅pi
– where pi < pk and n is a positive integer; for all Ti and Tk
– This is true for many real-world systems
22
Optimality of RM and DM Algorithms

• Theorem: 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
– Corollary: The same is true for the DM algorithm

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

• Fixed priority algorithms are predictable and do not


suffer from scheduling anomalies
– The worst case execution time of the system occurs with
the worst case execution time of the jobs
– Unlike dynamic priority algorithms, which can exhibit
anomalous behaviour
• Use this as the basis for a general schedulability test:
1. Find the critical instant when the system is most loaded,
and has its worst response time
2. Use time demand analysis to determine if the system is
schedulable at that instant
3. Prove that, if a fixed-priority system is schedulable at the
critical instant, it is always schedulable 25
T = {(8, 3), (9, 3), (15, 3)}
• Sol: URM(3) ≈ 0.780
• U = 3/8 + 3/9 + 3/15 = 0.908
schedulable utilization test

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

All tasks are schedulable under RM, therefore the


system is schedulable under RM. 26
1. Finding the Critical Instant

27
Finding the Critical Instant (Contd.,)

28/21
Finding the Critical Instant (Contd.,)

29
Using the Critical Instant

• Having determined the critical instants, show that for


each job Ji,c released at a critical instant, that job and
all higher priority tasks complete executing before
their relative deadlines
• If so, the entire system be schedulable…

• That is: don’t simulate the entire system, simply show


that it has correct characteristics following a critical
instant
– This process is called time demand analysis

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

• Use the time-demand analysis method to show that the


rate-monotonic algorithm will produce a feasible
schedule of the tasks T(d,e) T1(10,2), T2(8,3) and
T3(7,2)
• Ans: U= 2/10 + 3/8 + 2/7 = 0.86
• W1(10)=1 <= 10 T1 is schedulable
• W2(10) = 2+ceil(10/10).1=3 T2 is schedulable
(3<=10)
• W3(10)=2 +3 + ceil(10/10). 1+ceil(10/8).2=10
• (10<=10) T3 is schedulable
37
Practical Factors

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

You might also like