Upload
khakhariahetal
View
220
Download
0
Embed Size (px)
Citation preview
7/29/2019 Priority Driven Scheduling
1/49
BITS PilaniPilani | Dubai | Goa | Hyderabad
BITS C 553
Chapter 6 and 7Swati Keskar
7/29/2019 Priority Driven Scheduling
2/49
BITS PilaniPilani | Dubai | Goa | Hyderabad
Real-Time Systems : Scheduling
7/29/2019 Priority Driven Scheduling
3/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Plan of The Lecture
September 21, 2013 Swati Keskar 1-3
Priority-driven scheduling
Scheduling aperiodic jobs
7/29/2019 Priority Driven Scheduling
4/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Priority-Driven scheduling
Before starting the discussion, we assume that
The tasks are independent
There are no aperiodic and sporadic jobs
Job is ready for execution as soon as it is released Jobs are preemptible and never suspends itself
Scheduling decisions are made immediately upon job
releases and completion
Context switch overhead is negligible
September 21, 2013 Swati Keskar 4
7/29/2019 Priority Driven Scheduling
5/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Priority-Driven scheduling
It is an on-line scheduler, does not precompute the
schedule
It assigns the priorities to the job after they are released
and places the jobs in ready queue
Two main classifications
Fixed priority: assigns the same priority to all the jobs in
each task Dynamic priority: assigns different priorities to the
individual jobs in each task
September 21, 2013 Swati Keskar 5
7/29/2019 Priority Driven Scheduling
6/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Fixed Priority Algorithms
Rate-Monotonic Algorithm RMA
shorter the period, the higher the priority i.e. higher the
rate of occurrence, higher the priority
Deadline-Monotonic Algorithm DMAshorter the relative deadline, higher the priority
September 21, 2013 Swati Keskar 6
7/29/2019 Priority Driven Scheduling
7/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example
Consider a task set T1(7,3) , T2(12,3), T3(20,5)
September 21, 2013 7Swati Keskar
7/29/2019 Priority Driven Scheduling
8/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Dynamic Priority algorithms
Earliest Deadline First (EDF)
assigns the priority to individual jobs in the tasks
according to their absolute deadlines
LeastSlack-Time-first (LST)the scheduler checks the slacks of al the ready jobs
each time a new job is released then the smaller the
slack, the higher the priority
FIFO, LIFO etc
September 21, 2013 Swati Keskar 8
7/29/2019 Priority Driven Scheduling
9/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Schedulable Utilization
A scheduling algorithm can feasibly schedule any set of
periodic tasks on a processor if the total utilization of the
tasks is equal to or less than the schedulable utilization
of the algorithm
Higher the schedulable utilization of an algorithm , the
better the algorithm
A scheduling algorithm whose schedulable utilization is
equal to 1 is an optimal algorithm
September 21, 2013 Swati Keskar 9
7/29/2019 Priority Driven Scheduling
10/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
EDF Algorithm
A system T of independent, preemptable tasks with
relative deadlines equal to their respective periods can
be feasibly scheduled on one processor if and only if its
total utilization is equal to or less than 1
ek
UEDF = ---------------- 1
min(Dk,pk)
September 21, 2013 Swati Keskar 10
7/29/2019 Priority Driven Scheduling
11/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
RMA and DMA
A system of simply periodic, independent, preemptible
tasks whose relative deadlines are equal to or larger
than their periods is schedulable on one processor
according to the RM algorithm if and only if its total
utilization is equal to or less than 1
September 21, 2013 Swati Keskar 11
7/29/2019 Priority Driven Scheduling
12/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Schedulability Test
Schedulability test for tasks with short response times ie
where the response times of the jobs are smaller than or
equal to their respective periods
Every job completes before the next job in the same task
is released
We have to the critical instant
September 21, 2013 Swati Keskar 12
7/29/2019 Priority Driven Scheduling
13/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Critical Instant
A critical instant of a task Ti is a time instant which is
such that the job in Ti released at the instant has the
maximum response time.
This maximum response time is called Worst Case
Execution Time and is denoted by Wi
Theorem: In a fixed priority system where every job
completes before the next job in the same task is
released, a critical instant of any task Ti occurs when one
of its job Ji,c is released at the same time with a job inevery higher priority task
September 21, 2013 Swati Keskar 13
7/29/2019 Priority Driven Scheduling
14/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Time Demand Analysis
To determine whether a task can meet all its deadlines,
we have to compute the total demand for processor time
by a job released at a critical instant of the task and by
all the higher priority tasks at that critical instant
We will then check whether this demand can be met
before the deadline of the job
This test is called Time Demand analysis
Wi(t) = ei + t/pk ek for 0< t pi
This Wi(t) t for some t Di
September 21, 2013 Swati Keskar 14
7/29/2019 Priority Driven Scheduling
15/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example
A task set T1(7,3); T2(12,3) and T3(20,5) is Given. It is
scheduled by using Rate Monotonic Algorithm. Check its
schedulability.
September 21, 2013 Swati Keskar 15
7/29/2019 Priority Driven Scheduling
16/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Busy Interval
Here is a schedulability test for fixed-priority tasks witharbitrary response time
When relative deadline are larger than their respectiveperiods, we have to determine the schedulability
Approach is find the busy interval and then apply timedemand analysis test
A level-i busy interval (t0,t ] starts at an instant t0 when
All jobs in Ti released before the instant have completed
A job in Ti is releasedThe interval ends at the first instant t after to when all jobs
in Ti released since t0 are complete
September 21, 2013 Swati Keskar 16
7/29/2019 Priority Driven Scheduling
17/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Sufficient Schedulability condition
Schedulable utilization of RM and DM Algorithms for
tasks with Di = Pi gives us a flexible design guidelines for
the choices of the periods and execution times of the
tasks
Theorem : A system of n independent, preemptible
periodic tasks with relative deadlines equal to their
respective periods can be feasibly scheduled on a
processor according to the RMA if its total utilization U is
less than or equal to
URM(n) = n(21/n -1) and U URM
September 21, 2013 Swati Keskar 17
7/29/2019 Priority Driven Scheduling
18/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
URM as a Function of Task Parameters
Schedulable utilization as a function task utilization
Schedulable utilization of simply periodic tasks
Period ratio
Values of periods Tasks with arbitrary relative deadlines
September 21, 2013 Swati Keskar 18
7/29/2019 Priority Driven Scheduling
19/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Practical Factors
Assumptions we have made at the starting are not
always valid. Considering the practical factors, blocking
and priority inversion has to be discussed
Nonpreemptivity
Self suspension
Context switches
Limited priority levels
Tick Scheduling
September 21, 2013 Swati Keskar 19
7/29/2019 Priority Driven Scheduling
20/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Tick Scheduling
We are assuming that the scheduler is event-driven
This assumption is always not valid, sometimes the scheduler
is time-driven
Scheduling decisions are made at these time instants called
clock interrupts
This method is also called time-based scheduling and
scheduler executes only at clock interrupts
September 21, 2013 20Swati Keskar
7/29/2019 Priority Driven Scheduling
21/49BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example
September 21, 2013 21Swati Keskar
7/29/2019 Priority Driven Scheduling
22/49
16/08/2010 22Swati Keskar BITS Pilani
7/29/2019 Priority Driven Scheduling
23/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Scheduling Aperiodic and
Sporadic Jobs
We assume that the operating system maintains the priority
queue.
The ready periodic tasks are placed in the periodic task queue
according to their priority assigned by any one of the
algorithms
Each accepted sporadic job is assigned a priority and is placed
in priority queue
Each newly arrived aperiodic job is placed in the aperiodic job
queue
September 21, 2013 23Swati Keskar
7/29/2019 Priority Driven Scheduling
24/49
September 21, 2013 24Swati Keskar
7/29/2019 Priority Driven Scheduling
25/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Alternative approaches
Background execution
Polled execution
Interrupt driven execution
September 21, 2013 25Swati Keskar
7/29/2019 Priority Driven Scheduling
26/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Background Execution
Aperiodic jobs are scheduled and executed only at times
when there is no periodic or sporadic job ready for execution
Always produces correct schedules
Simple to implement
Drawback is that the execution of aperiodic jobs is delayed
and response time is prolonged
September 21, 2013 26Swati Keskar
7/29/2019 Priority Driven Scheduling
27/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Interrupt Driven Execution
Whenever an aperiodic job arrives, the execution of periodic
tasks are interrupted and the aperiodic job is executed.
In this case, aperiodic job may have the shortest possible
response time
But it has main disadvantage that if aperiodic job always
execute as soon as possible ,periodic task may miss some
deadlines
September 21, 2013 27Swati Keskar
7/29/2019 Priority Driven Scheduling
28/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Polling Server
A poller or polling server is a periodic task whose polling
period is ps and es is its execution time
The poller is ready for execution periodically and is scheduled
together with the periodic tasks in the system
When it executes, it examines the aperiodic job queue
If the queue is nonempty, the poller executes the job at the
head of the queue
Server suspends its execution when either budget is
exhausted or when the queue becomes empty
September 21, 2013 28Swati Keskar
7/29/2019 Priority Driven Scheduling
29/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Polling Server
The main disadvantage of poling server is that if at the
beginning of a polling period the poller finds the aperiodic job
queue empty , it suspends immediately
It will not be ready for execution and able to examine the
queue again until the next polling period
September 21, 2013 29Swati Keskar
7/29/2019 Priority Driven Scheduling
30/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Periodic Server
The periodic server is nothing but a periodic task created for
the purpose of executing aperiodic jobs
It has period ps and execution time es which is called as
execution budget or simply budget
The ratio us = es/ps is the size of the server
At the beginning of each period, the budget of the poller is set
to es i.e. its budget is replenished
September 21, 2013 30Swati Keskar
7/29/2019 Priority Driven Scheduling
31/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Periodic Server
The periodic server is backlogged whenever the aperiodic job
queue is nonempty and there is at least an aperiodic job to be
executed by the server
The server is idle when the queue is empty
The server is eligible for execution only when it is backlogged
and budget
When the server is scheduled and executes aperiodic jobs, it
consumes its budget at the rate of one per unit time
The server budget becomes exhausted when the budget
becomes zero
September 21, 2013 31Swati Keskar
7/29/2019 Priority Driven Scheduling
32/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Bandwidth-preserving Servers
If we can preserve the execution budget of the poller when it
finds an empty queue and allow it to execute later in the
period if any aperiodic job arrives, we can improve the
response time of aperiodic job
Algorithms that improve the polling approach in ths mannerare called bandwidth preserving server algorithm
These are periodic servers, each type of server is defined by a
set of consumption and replenishment rules
September 21, 2013 32Swati Keskar
7/29/2019 Priority Driven Scheduling
33/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Types of bandwidth-preserving servers
Deferrable servers
Sporadic servers
Constant utilization/total bandwidth servers and weightedfair-queuing servers
Bandwidth-preserving Servers
September 21, 2013 33Swati Keskar
7/29/2019 Priority Driven Scheduling
34/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Deferrable servers
Consumption rule: The execution budget of the server is
consumed at the rate of one per unit time whenever the
server executes
Replenishment rule : The execution budget of the server is set
to es at time instants kpkfor k = 0,1,2
September 21, 2013 34Swati Keskar
7/29/2019 Priority Driven Scheduling
35/49
September 21, 2013 35Swati Keskar
7/29/2019 Priority Driven Scheduling
36/49
September 21, 2013 36Swati Keskar
7/29/2019 Priority Driven Scheduling
37/49
September 21, 2013 37Swati Keskar
7/29/2019 Priority Driven Scheduling
38/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Schedulability with deferrable Server
Time demand analysis can be used to determine whether all
the periodic tasks remain schedulable in the presence of a
deferrable server (highest priority)
The time demand function of the task Ti in presence of
deferrable server is given by
September 21, 2013 38Swati Keskar
7/29/2019 Priority Driven Scheduling
39/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Schedulable Utilization
Schedulability of a fixed-priority system in which a deferrable
server is scheduled at an arbitrary priority cannot be assured
Only exception is when the deferrable server has shortest
period in a system of n tasks and the system is scheduled rate-
monotonically
September 21, 2013 39Swati Keskar
7/29/2019 Priority Driven Scheduling
40/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Theorem for Schedulable Utilization
Consider a system of n independent, preemptible periodic
tasks whose periods satisfy the inequalities
ps < p1 < p2< < pn < 2ps and pn > ps + es and whose relative
deadlines are equal to their respective periods.
This system is schedulable rate-monotonically with a
deferrable server (ps, es) if their total utilization is less than or
equal to
September 21, 2013 40Swati Keskar
7/29/2019 Priority Driven Scheduling
41/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
When the servers period is arbitrary, we can use URM(n) to
determine whether each periodic task Ti is schedulable if the
periodic tasks and the server are scheduled rate-
monotonically
We can treat additional es units of time as additional blockingtime of the task Ti. Ti is surely schedulable if
Theorem for Schedulable Utilization
September 21, 2013 41Swati Keskar
7/29/2019 Priority Driven Scheduling
42/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Schedulability with deadline-driven systems
A periodic task Ti in a system of n independent, preemptive
periodic tasks is schedulable with a deferrable server with
period ps, execution budget es and utilization us, according to
the EDF algorithm if
September 21, 2013 42Swati Keskar
7/29/2019 Priority Driven Scheduling
43/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Sporadic Servers
Improved version of deferrable servers
The consumption and replenishment rules of this server
ensure that each sporadic server with period ps and budget es
never demands more processor time than the periodic task
(ps,es) in any time interval
We can treat the sporadic server exactly like the periodic task
when we check for the schedulability of the system
A system of periodic tasks containing a sporadic server may be
schedulable while the same system containing a deferrableserver with same parameters is not
September 21, 2013 43Swati Keskar
7/29/2019 Priority Driven Scheduling
44/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Simple Sporadic Server
Consumption rules : at any time t after tr ie replenishment
time, the servers budget is consumed at the rate of 1 unit per
time until the budget is exhausted when either one of the
following conditions are true
C1 : The server is executing
C2: The server has executed since tr and END
7/29/2019 Priority Driven Scheduling
45/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Replenishment Rules
Replenishment rules of Simple Fixed-Priority-Sporadic server
are
R1 : Initially when the system begins execution and each time
when the budget is replenished, the execution budget = es
and tr = the current time
R2: At the time tf(first instant after tr when server begins
execution), if END = tf, te = max( tr, BEGIN). If END < tf,
te=tf. The next replenishment time is set at te+ps
September 21, 2013 45Swati Keskar
7/29/2019 Priority Driven Scheduling
46/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Replenishment Rules
R3 : The next replenishment occurs at the next replenishment
time, except under the following conditions
If the next replenishment time te + ps is earlier than tf, the
budget is replenished as soon as it is exhausted
If the system T becomes idle before the next replenishment
time te + ps , and becomes busy again at tb, the budget is
replenished at min( te+ps, tb).
September 21, 2013 46Swati Keskar
7/29/2019 Priority Driven Scheduling
47/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Scheduling of Sporadic Jobs
The scheduler performs an acceptance test on each sporadic
job upon its arrival
The acceptance tests are performed on sporadic jobs in the
EDF order
Once accepted, sporadic jobs are ordered among themselves
in the EDF order
September 21, 2013 47Swati Keskar
7/29/2019 Priority Driven Scheduling
48/49
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Acceptance Test
For deadline-driven system
For first sporadic job S (t,d,e), the scheduler accepts S if its
density e/(d-t) < 1-
For new sporadic jobs , the scheduler accepts the job S if
e / (d t) + s,k 1- for all k = 1,2
September 21, 2013 48Swati Keskar
7/29/2019 Priority Driven Scheduling
49/49
For fixed-priority systems
For first sporadic job, find slack time
s,1(t) = (ds,1-t)/ps es es,1 0
For next sporadic jobs, the scheduler computes the slack
s,I according to
s,i(t) = (ds,i-t)/ps es es,I (es,k - s,k) 0
Acceptance Test