0% found this document useful (0 votes)
3 views

lecture05e

The document discusses priority-driven scheduling of periodic tasks, focusing on fixed-priority algorithms like Rate Monotonic and Deadline Monotonic, as well as dynamic-priority algorithms such as Earliest Deadline First and Least Slack Time. It outlines the assumptions for scheduling, compares the merits of different algorithms, and introduces concepts like schedulable utilization and tests for schedulability. The document emphasizes the importance of understanding these scheduling strategies for real-time systems development.

Uploaded by

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

lecture05e

The document discusses priority-driven scheduling of periodic tasks, focusing on fixed-priority algorithms like Rate Monotonic and Deadline Monotonic, as well as dynamic-priority algorithms such as Earliest Deadline First and Least Slack Time. It outlines the assumptions for scheduling, compares the merits of different algorithms, and introduces concepts like schedulable utilization and tests for schedulability. The document emphasizes the importance of understanding these scheduling strategies for real-time systems development.

Uploaded by

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

Priority-driven

Scheduling of Periodic
Tasks – Part 1

COE186 | Real-Time Systems Development

Slides from
Dr Colin Perkins
Real-Time and Embedded Systems
University of Glasgow
1
Lecture Outline
• Assumptions
• Fixed-priority algorithms
– Rate monotonic
– Deadline monotonic
• Dynamic-priority algorithms
– Earliest deadline first
– Least slack time
• Relative merits of fixed- and dynamic-priority scheduling
• Schedulable utilization and proof of schedulability

Material in lectures 5 & 6 corresponds to chapter 6 of Liu’s book

Priority-driven Scheduling of Periodic Tasks – Part 1 2


Assumptions
• Priority-driven scheduling of periodic tasks on a single processor
• Assume a restricted periodic task model:
– A fixed number of independent periodic tasks exist
• Jobs comprising those tasks:
– Are ready for execution as soon as they are released
– Can be pre-empted at any time
– Never suspend themselves
• New tasks only admitted after an acceptance test; may be rejected
• The period of a task defined as minimum inter-release time of jobs in task
– There are no aperiodic or sporadic tasks
– Scheduling decisions made immediately upon job release and completion
• Algorithms are event driven, not clock driven
• Never intentionally leave a resource idle
– Context switch overhead negligibly small; unlimited priority levels

Priority-driven Scheduling of Periodic Tasks – Part 1 3


Dynamic versus Static Systems
• Recall from lecture on Overview of Real-Time Scheduling:
– 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

Priority-driven Scheduling of Periodic Tasks – Part 1 4


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

Priority-driven Scheduling of Periodic Tasks – Part 1 5


Rate Monotonic Scheduling
• 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
• Very widely studied and used

• For example, consider a system of 3 tasks:


– T1 = (4, 1) ⇒ rate = 1/4
– T2 = (5, 2) ⇒ rate = 1/5
– T3 = (20, 5) ⇒ rate = 1/20

– Relative priorities: T1 > T2 > T3

Priority-driven Scheduling of Periodic Tasks – Part 1 6


Example: Rate Monotonic Scheduling
Time Ready to run Running Time Ready to run Running
0 10
1 11
2 12
3 13
4 14
5 15
6 16
7 17
8 18
9 19

J1,1 J1,2 J1,3 J1,4 J1,5


T1 = (4, 1)
Released

J2,1 J2,2 J2,3 J2,4


J3,1 T2 = (5, 2)
T3 = (20, 5)

0 4 8 12 16 20
Priority-driven Scheduling of Periodic Tasks – Part 1 7
Deadline Monotonic Scheduling
• 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 rate monotonic


– If deadline ≠ period

Priority-driven Scheduling of Periodic Tasks – Part 1 8


Dynamic-Priority Algorithms
• Discussed several dynamic-priority algorithms in lecture:
Overview of Real-Time Scheduling:
– 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

• Focus on EDF as commonly used example


Priority-driven Scheduling of Periodic Tasks – Part 1 9
Example: Earliest Deadline First
Time Ready to run Running Time Ready to run Running

J1,1 J1,2 J1,3 J1,4 J1,5 J1,6


T1 = (2, 1)
Released

J2,1 J2,2 J2,3


T2 = (5, 2.5)

0 1 2 3 4 5 6 7 8 9 10

Priority-driven Scheduling of Periodic Tasks – Part 1 10


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
• Dynamic algorithms like EDF can produce feasible schedules in
cases where RM and DM cannot
– But fixed priority algorithms often more predictable, lower overhead

Priority-driven Scheduling of Periodic Tasks – Part 1 11


Example: Comparing Different Algorithms

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


• Assume a single processor system with 2 tasks:
– T1 = (2, 1)
– T2 = (5, 2.5) H = 10

• 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

Priority-driven Scheduling of Periodic Tasks – Part 1 12


Example: RM, EDF, LST and FIFO
J1,1 J1,2 J1,3 J1,4 J1,5
Deadlines J2,1 J2,2

FIFO J1,1 J2,1 J1, 2 J1,3 J2,2 J1,4 J1,5

LST J1,1 J2,1 J1,2 J2,1 J1,3 J2,2 J1,4 J2,2 J1,5 J2,2

EDF J1,1 J2,1 J1,2 J2,1 J1,3 J2,2 J1,4 J2,2 J1,5 J2,2

RM J1,1 J2,1 J1,2 J2,1 J1,3 J2,1 J2,2 J1,4 J2,2 J1,5 J2,2

0 2 4 6 8 10

• Demonstrate by exhaustive simulation that LST and EDF meet


deadlines, but FIFO and RM don’t
Priority-driven Scheduling of Periodic Tasks – Part 1 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

Priority-driven Scheduling of Periodic Tasks – Part 1 14


Schedulable Utilization
• Recall: a periodic task Ti is defined by the 4-tuple (ϕi, pi, ei, Di)
with utilization ui = ei / pi
• Total utilization of the system U = ∑i=1 ui where 0 ≤ U ≤ 1
n

• A scheduling algorithm can feasibly schedule any system of


periodic tasks on a processor if U is equal to or less than the
maximum schedulable utilization of the algorithm, UALG
– If UALG = 1, the algorithm is optimal

• Why is knowing of UALG important? It gives a schedulability test,


where a system can be validated by showing that U ≤ UALG

Priority-driven Scheduling of Periodic Tasks – Part 1 15


Schedulable Utilization: EDF
• Theorem: a system of independent preemptable periodic tasks
with Di = pi can be feasibly scheduled on one processor using
EDF if and only if U ≤ 1
– UEDF = 1 for independent, preemptable periodic tasks with Di = pi
[Expected since EDF proved optimal
in lecture 3 – see the book for proof]
– Corollary: result also holds if deadline longer than period: UEDF = 1 for
independent preemptable periodic tasks with Di ≥ pi

• Notes:
– Result is independent of ϕi
– Result can also be shown to apply to strict LST

Priority-driven Scheduling of Periodic Tasks – Part 1 16


Schedulable Utilization: EDF
• What happens if Di < pi for some i? The test doesn’t work…
– E.g. T1 = (2, 0.8), T2=(5, 2.3, 3)
J2,1 is preempted and misses deadline

J1,1 J2,1 J1,2 J2,1 J1,3 J2,2 J1,4 J2,2

0 1 2 3 4 5 6 7

• However, there is an alternative test:


– The density of the task, Ti, is δi = ei / min(Di, pi)
– The density of the system is ∆ = δ1 + δ2 + … + δn
– Theorem: A system T of independent, preemptable periodic tasks can be
feasibly scheduled on one processor using EDT if ∆ ≤ 1.
• Note:
– This is a sufficient condition, but not a necessary condition – i.e. a system
is guaranteed to be feasible if ∆ ≤ 1, but might still be feasible if ∆ > 1
(would have to run the exhaustive simulation to prove)
Priority-driven Scheduling of Periodic Tasks – Part 1 17
Schedulable Utilization: EDF
• How can you use this in practice?
– Assume using EDF to schedule multiple periodic tasks, known execution
time for all jobs
⇒ Choose the periods for the tasks such that the schedulability test is met

• Example: a simple digital controller:


– Control-law computation task, T1, takes e1 = 8 ms, sampling rate is 100 Hz
(i.e. p1 = 10 ms)
⇒ u1 is 0.8
⇒ the system is guaranteed to be schedulable
– Want to add a built-in self test task, T2, taking 50ms - will the system still
work?
Copyright © 2006 University of Glasgow
All rights reserved.

Priority-driven Scheduling of Periodic Tasks – Part 1 18


Schedulable Utilization of RM
• Theorem: a system of n independent preemptable periodic tasks
with Di = pi can be feasibly scheduled on one processor using RM
if U ≤ n⋅(21/n – 1)
URM(n)

– URM(n) = n⋅(21/n – 1) 0.9


– For large n → ln 2
(i.e. n → 0.69314718056…) 0.8

– [Proof in book - complicated!] 0.7

0.6 n
2 4 6 8 10 12 14 16 18

– U ≤ URM(n) is a sufficient, but not necessary, condition – i.e. a feasible rate


monotonic schedule is guaranteed to exist if U ≤ URM(n), but might still be
possible if U > URM(n)
Priority-driven Scheduling of Periodic Tasks – Part 1 19
Schedulable Utilization of RM
• What happens if the relative deadlines for tasks are not equal to
their respective periods?
• Assume the deadline is some multiple υ of the period: Dk = υ⋅pk
• It can be shown that:

Priority-driven Scheduling of Periodic Tasks – Part 1 20


Schedulable Utilization of RM
n υ = 4.0 υ = 3.0 υ = 2.0 υ = 1.0 υ = 0.9 υ = 0.8 υ = 0.7 υ = 0.6 υ = 0.5
2 0.944 0.928 0.898 0.828 0.783 0.729 0.666 0.590 0.500
3 0.926 0.906 0.868 0.779 0.749 0.708 0.656 0.588 0.500
4 0.917 0.894 0.853 0.756 0.733 0.698 0.651 0.586 0.500
5 0.912 0.888 0.844 0.743 0.723 0.692 0.648 0.585 0.500
6 0.909 0.884 0.838 0.734 0.717 0.688 0.646 0.585 0.500
7 0.906 0.881 0.834 0.728 0.713 0.686 0.644 0.584 0.500
8 0.905 0.878 0.831 0.724 0.709 0.684 0.643 0.584 0.500
9 0.903 0.876 0.829 0.720 0.707 0.682 0.642 0.584 0.500
∞ 0.892 0.863 0.810 0.693 0.687 0.670 0.636 0.582 0.500

Di > pi ⇒ Schedulable Di < pi ⇒ Schedulable


utilization increases util ization decreases

Di = pi

Priority-driven Scheduling of Periodic Tasks – Part 1 21


Summary
Key points:
• Different priority scheduling algorithms
– Earliest deadline first, least slack time, rate monotonic, deadline monotonic
– Each has different properties, suited for different scenarios
• Scheduling tests, concept of maximum schedulable utilization
– Examples for different algorithms

Next lecture: practical factors, more schedulability tests…

Priority-driven Scheduling of Periodic Tasks – Part 1 22

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy