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

RTS Lecture 4 1644141180167

The document discusses task scheduling algorithms for uniprocessor systems. It describes Rate Monotonic (RM) and Earliest Deadline First (EDF) scheduling algorithms. RM assigns static priorities based on task periods, with higher priority given to tasks with shorter periods. EDF uses dynamic priorities and schedules the task with the earliest deadline first. The document also discusses frame-based scheduling, job characteristics, fixed vs dynamic priority scheduling, and compares the relative merits of different algorithms.

Uploaded by

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

RTS Lecture 4 1644141180167

The document discusses task scheduling algorithms for uniprocessor systems. It describes Rate Monotonic (RM) and Earliest Deadline First (EDF) scheduling algorithms. RM assigns static priorities based on task periods, with higher priority given to tasks with shorter periods. EDF uses dynamic priorities and schedules the task with the earliest deadline first. The document also discusses frame-based scheduling, job characteristics, fixed vs dynamic priority scheduling, and compares the relative merits of different algorithms.

Uploaded by

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

BITS Pilani

presentation
BITS Pilani Pawan Gupta
Pilani Campus
BITS Pilani
Pilani Campus

SS ZG553, Real Time Systems


Lecture No 4.
Task Allocation and Scheduli
ng
 
How to assign tasks to processors and to schedule them
in such a way that deadlines are met
• Our initial focus: uniprocessor task scheduling

BITS Pilani, Pilani Campus


Standard Scheduling Algorit
hms
 
 Rate-Monotonic (RM) Algorithm:
– • Static priority
– • Higher-frequency tasks have higher priority

• Earliest-Deadline First (EDF) Algorithm:


– • Dynamic priority
– • Task with the earliest absolute deadline has highest priority

BITS Pilani, Pilani Campus


 Rate-Monotonic (RM)
Algorithm:
The task set consists of
Periodic
Pre-emptible task
Deadline equals the tasks period
Task Priorities are static and inversely related to its periods
Optimal static priority uniprocessor
Variant:
Rate Monotonic Deferred server: It handles both periodic
( With deadline equal to period) and aperiodic tasks

BITS Pilani, Pilani Campus


EDF ( Earliest Deadline
First)
Tasks are preemptible and the task with the earliest
absolute deadline has the highest priority
Optimal dynamic Uniprocessor Algorithm
If a task set is not schedulable by a single processor by
EDF than there is no other processor that can
successfully schedule that task set
Dynamic priority scheduling Algorithm

BOTH RM and EDF assumes


Tasks are preemptible anytime and independent

BITS Pilani, Pilani Campus


IRIS

Increased Reward for Increased Service


Many algorithms has property that they can be stopped
early and still provide useful output
The quality of the output is a monotically non decreasing
function of execution time

BITS Pilani, Pilani Campus


Classical Uniprocessor
Assumptions
• No task has any nonpremtable section and the cost of
preemption is negligible
• Only processing requirements are significant;
memory I/O and other resource requirements are
negligible
• All tasks are independent and there are no
precedence constraints
RM additional assumptions
– All tasks in task set are periodic
– The relative deadline of a task is equal to its period

BITS Pilani, Pilani Campus


Clock Driven Scheduling
Clock-driven scheduling applicable to deterministic systems
A restricted periodic task model:
- The parameters of all periodic tasks are known a priori
– For each mode of operation, system has a fixed number, n, periodic tasks
• For task Ti each job Ji,k is ready for execution at its release time ri,k and is
released pi units of time after the previous job in Ti such that ri,k = ri,k-1 + pi
• Variations in the inter-release times of jobs in a periodic task are negligible
– Aperiodic jobs may exist
• Assume that the system maintains a single queue for aperiodic jobs
• Whenever the processor is available for aperiodic jobs, the job at the head of
this queue is executed
– There are no sporadic jobs

Recall: sporadic jobs have hard deadlines, aperiodic jobs


do not

BITS Pilani, Pilani Campus


Notation
The 4-tuple Ti = (φi, pi, ei, Di) refers to a periodic task Ti with
phase φi, period pi, execution time ei, and relative deadline Di
– Default phase of Ti is φ
i = 0, default relative deadline is the period Di = pi
– Omit elements of the tuple that have default values
– Examples:
T1 = (1, 10, 3, 6) ⇒ φ1 = 1 p1 = 10 e1 = 3 D1 = 6
T2 = (10, 3, 6) ⇒ φ2 = 0 p2 = 10 e2 = 3 D2 = 6
T3 = (10, 3) ⇒ φ3 = 0 p3 = 10 e3 = 3 D3 = 10
J1,1 released at 1, deadline 7
J1,2 released at 11, deadline 17

J1,1 released at 0, deadline 6
J1,2 released at 10, deadline 16

J1,1 released at 0, deadline 10
J1,2 released at 10, deadline 20

BITS Pilani, Pilani Campus


Static, Clock-driven Cyclic
Scheduler
• Since the parameters of all jobs with hard deadlines are known
can construct a static cyclic schedule in advance
– Processor time allocated to a job equals its maximum execution time
– Scheduler dispatches jobs according to the static schedule, repeating
each hyperperiod
– Static schedule guarantees that each job completes by its deadline
• No job overruns ⇒ all deadlines are met
• Schedule calculated off-line ⇒ can use complex algorithms
– Run-time of the scheduling algorithm irrelevant
– Can search for a schedule that optimizes some characteristic of the
system
• e.g. a schedule where the idle periods are nearly periodic;
accommodating aperiodic jobs

BITS Pilani, Pilani Campus


Example Cyclic Schedule
Consider a system with 4 independent periodic tasks:
– T1 = ( 4, 1.0)
– T2 = ( 5, 1.8) [Phase and deadline take default values]
– T3 = (20, 1.0)
– T4 = (20, 2.0)
• Hyper-period H = 20 (least common multiple of 4, 5, 20,
20)
• Can construct an arbitrary static schedule to meet all
deadlines:

BITS Pilani, Pilani Campus


Frame Size Constraints
How to choose frame length?
– To avoid preemption, want jobs to start and complete
execution within a single frame:
f ≥ max(e1, e2, …, en) (Eq.1)
– To minimize the number of entries in the cyclic schedule, the
hyper-period should be an integer multiple of the frame size
(⇒ f divides evenly into the period of at least one task):
∃ i : mod(pi, f ) = 0 (Eq.2)
– To allow scheduler to check that jobs complete by their
deadline, should be at least one frame boundary between
release time of a job and its deadline:
2*f – gcd(pi, f ) ≤ Di for i = 1, 2, …, n (Eq.3)]
• All 3 constraints should be satisfied

BITS Pilani, Pilani Campus


Frame Size Constraints –
Example
Review the system of independent periodic tasks from our earlier
example:
T1 = (4, 1.0) T2 = (5, 1.8)
T3 = (20, 1.0) T4 = (20, 2.0)
Hyperperiod = LCM of Periods ( 4,5,20,20) = 20
• Constraints:
Eq.1 ⇒ f ≥ max(1, 1.8, 1, 2) ≥ 2
Eq.2 ⇒ f ∈ { 2, 4, 5, 10, 20 }
---2*f – gcd(pi, f ) ≤ Di
Eq.3 ⇒ 2f - gcd( 4, f ) ≤ 4 (T1)
2f - gcd( 5, f ) ≤ 5 (T2)
2f - gcd(20, f ) ≤ 20 (T3, T4)

BITS Pilani, Pilani Campus


Fixed-Priority Scheduling - 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 priorités: T1 > T2 > T3

BITS Pilani, Pilani Campus


Example: Rate Monotonic
Scheduling

BITS Pilani, Pilani Campus


Job Characteristic

BITS Pilani, Pilani Campus


Fixed-Priority Scheduling: Deadline-
Monotonic
• 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

BITS Pilani, Pilani Campus


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
• Focus on EDF as commonly used example

BITS Pilani, Pilani Campus


Example: Earliest Deadline First
Time Ready to run Running Time Ready to run Running
T1 = (2, 1)
T2 = (5, 2.5)
J1,1 J1,2 J1,3 J1,4 J1,5
J2,1 J2,2 J2,3
Released
J1,6
0 1 2 3 4 5 6 7 8 9 10

BITS Pilani, Pilani Campus


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

BITS Pilani, Pilani Campus

You might also like