No Slide Title
Download
Report
Transcript No Slide Title
Real Time Operating Systems
Schedulability Part 2
Course originally developed by
Maj Ron Smith
7/21/2015
Dr Alain Beaulieu
1
Outline
Review of RMA and Utilization Bound Testing
Revisiting Critical Instances
Time Demand Analysis
Schedulability & Aperiodic Tasks
Deadline Monotonic Priority Algorithm
Schedulability & Bandwidth Preserving Servers
Deferrable Server Schedulability
7/21/2015
Dr Alain Beaulieu
Utilization based schedulability tests
pros:
usually involves a “simple” computational test
mathematically rigorous
Seminal paper
cons:
not always conclusive
sufficient but not necessary
only valid if the workload model and the underlying
assumptions of the test are consistent
can lead to false confidence
7/21/2015
Dr Alain Beaulieu
Alternatives
When utilization based tests are inconclusive, we can
always construct a timing graph of the system
construct graph over the interval [0, max {pi}]
if all tasks meet their deadlines within their first period,
the system is schedulable
assumes that all tasks are in phase
the problem with this approach is that it will be impractical
for most large systems and is not easily automated
As experienced in the first homework
alternative: time-demand analysis
7/21/2015
Dr Alain Beaulieu
Revisiting Critical Instants
Recall that a critical instant is defined as the instant
in time that a job is released such that it has the
maximum response time of all jobs in the task
think of it as the worst possible time (busiest) to release on
the processor
Theorem: in a fixed priority system (where every job in
a task completes before another job in the same task releases),
the critical instant for Ti occurs when it releases at
the same time as a job in each higher priority task
7/21/2015
Dr Alain Beaulieu
Critical Instants
Example 1:
T= { (3,1), (5, 1), (10, 2) }
T1
1
T2
1
1
1
1
1
T3
1
0
1
2
1
1
4
6
8
10
12
The critical instant for tasks T2 and T3 is 0
In fact for in phase tasks, a critical instant always exists at t = 0
7/21/2015
Dr Alain Beaulieu
Critical Instants
Example 2:
T= { (1,3,1,3), (5, 1), (10, 2) }
T1
1
T2
1
1
1
1
1
T3
1
0
1
2
1
1
4
6
8
10
The critical instant for tasks T2 and T3 is 10
7/21/2015
Dr Alain Beaulieu
12
Time-Demand Analysis (Di ≤ pi)
Under time-demand analysis we:
predict the worst case response time for each task going
from highest priority to lowest
then compare each task’s response time to its deadline
if all worst case response times are less than their
respective deadlines, the system is schedulable
Recall that a tasks response time is its completion
time minus its release time
This technique is sometimes referred to as response time analysis
7/21/2015
Dr Alain Beaulieu
Worst-Case Response Time
Alternatively, the response time of a task is defined to
be the sum of its own worst case computation time and
its maximum interference ->
wi = ei + Ii
(1)
where Ii is the maximum interference* that task i can experience in
any time interval [t, wi )
*The condition for maximum interference obviously occurs
when all higher priority tasks are released at the same time
as task i (in other words, at a critical instant)
7/21/2015
Dr Alain Beaulieu
Counting Releases
Consider task i and a higher priority task j
now, the number of releases of task j in time interval 0
to wi can be derived as follows:
# of releases j = wi/pj
(2)
[ 0, wi )
ceiling function
i
40
j
5
40
0
7/21/2015
# of releases = 2
40
pj
100
wi
pi
Dr Alain Beaulieu
200
Determining Interference
From this, the maximum interference of task j on task
i in interval 0 to wi is given by:
max interference (task j) = wi/pj ej
[ 0, wi )
(3)
but there may be other higher priority tasks,
therefore:
Ii =
wi/pj ej
(4)
jhp(i)
7/21/2015
Dr Alain Beaulieu
Calculating Response Time
Substituting equation (4) into (1) gives the general
expression for response time:
wi = ei + wi/pj ej
(5)
jhp(i)
Note the following issue (problem):
wi is on both sides of this “strange” equation
Before we attempt to solve this equation, let’s first
see if we can understand it
7/21/2015
Dr Alain Beaulieu
Understanding Response Time
T = { (100, 20), (150, 30), (250, 60) }
w3 = e3 + w3/p1 e1 + w3/p2 e2
= 60 + 2(20) + 1(30) {by viewing the graph}
= 130
T1
w3 = 130
T2
T3
0
7/21/2015
100
200
Dr Alain Beaulieu
Solving the Response Time Equation
Essentially, form a recursive relationship with
equation (5) and solve iteratively:
win+1 = ei + win / pj ej
(6)
jhp(i)
where initial (seed) value wi0 = ei
The algorithm then becomes:
solve for successive values of win+1
if win+1 = win , then solution found -> wi = win
if win+1 > Di , then task i cannot meet its deadline
7/21/2015
Dr Alain Beaulieu
Response Time Analysis Example
Given T = { (7,3), (12, 3), (20,5) }
Use RMA scheduling
Apply the utilization based schedulabilty test
If necessary, use time-demand analysis to determine
whether the system is schedulable
exercise to be completed in class
7/21/2015
Dr Alain Beaulieu
Schedulability & Asynchronous Tasks
The simple task model that we have been able to deal
with thus far is restrictive in several ways. Not being
able to handle asynchronous tasks is a major
restriction.
One approach is to make asynchronous tasks
resemble periodic tasks
consider that an asynchronous task’s minimum inter-arrival
time can be treated like a period, T
with just this assumption one can use RMA to extend to both
types of tasks, BUT
7/21/2015
Dr Alain Beaulieu
Deadline Monotonic Priority Ordering
The simple task model assumption that D=p is also
unrealistic for most asynchronous tasks
often, an asynchronous task will occur infrequently (large
inter-arrival time) but must be serviced quickly -> D < p
therefore priority assignment based upon p will usually not
satisfy the requirement to meet D
The deadline monotonic priority ordering (DMPO)
scheme is introduced as follows:
the shorter the task deadline, the higher the priority
7/21/2015
Dr Alain Beaulieu
DMPO Example
Task
1
2
3
4
ei
3
3
4
3
pi
20
15
10
20
Di
5
7
10
20
i
1
2
3
4
wi *
3
6
10
20
* Response times are calculated using the methods
presented earlier using equation (6)
Note that a rate monotonic ordering would not
schedule these tasks
7/21/2015
Dr Alain Beaulieu
Schedulability & BP Servers
Recall that a bandwidth preserving server is a type
of polling server that permits the budget of the
server to be preserved until later in the period
should an asynchronous job arrive
We described two general classes of bandwidth
preserving server:
deferrable server
sporadic server
How do we determine the schedulability of the system in
the presence of bandwidth preserving servers?
7/21/2015
Dr Alain Beaulieu
Recall: Deferrable Servers
A deferrable server is a bandwidth preserving server
with period ps and execution budget es which
preserves its budget if idle, and
replenishes its budget fully every period
Budgets are not allowed to accumulate from period to
period
Since the deferrable server is purely periodic, it can
be assigned priority along with all other periodic
tasks
… and, for reasons that will now be explained, we must
ensure that the priority of the deferrable server is higher
than all other periodic tasks
7/21/2015
Dr Alain Beaulieu
Recall the Deferrable Server Example
The schedule for this system is given below:
T= {(2, 3.5, 1.5, 3.5), (6, 0.5) }
TDS = (3,1)
A1 = (2.5, 2)
Note: = {TDS, T1, T2}
TDS
1/2
T1
1
1/2
1/2
T2
1
1/2
1
1/2
0
7/21/2015
1/2
2
2.5
4
5.5
6
Dr Alain Beaulieu
8
Critical Instants &
Systems with Deferrable Servers
In order to use time demand analysis on a system with
a deferrable server, a critical instant, t0, must be
found as follows:
at t0 a job of task i is released
a job in every higher priority task is also released at t0
a (higher priority) deferrable server has:
a full budget es at t0
an asynchronous job is released at t0,
a full asynchronous backlog exists for an extended time (beyond
wi), and
the next replenishment is at t0 + es
7/21/2015
Dr Alain Beaulieu
Critical Instants in Systems
with Deferrable Servers
To understand the critical instant in the presence of
a deferrable server, study the graph below
note how the worst case release time for any periodic task
occurs when TDS has (and uses) its full budget just prior to
getting a full replenishment
TDS
es
es
es
es
T1
T2
t0
7/21/2015
Dr Alain Beaulieu
es
Time-Demand Analysis with
Deferrable Servers (Di ≤ pi)
Understanding this formula:
wi = ei + es + (wi-es) / ps es + wi/pk ek
khp(i), excluding TDS
execution of deferrable
server immediately
following critical instant
7/21/2015
Dr Alain Beaulieu
Time-Demand Analysis with
Deferrable Servers (Di ≤ pi)
Understanding this formula:
wi = ei + es + (wi-es) / ps es + wi/pk ek
khp(i), excluding TDS
interference of the deferrable
server, TDS, in the interval
(t0+es , wi]
7/21/2015
Dr Alain Beaulieu
Time-Demand Analysis with
Deferrable Servers (Di ≤ pi)
Understanding this formula:
wi = ei + es + (wi-es) / ps es + wi/pk ek
khp(i), excluding TDS
interference of all k higher
priority tasks, excluding the
deferrable server, TDS
7/21/2015
Dr Alain Beaulieu
Exercise
Draw the schedule for the system below
(go out far enough in time to include as a minimum the
completion of the first job in each periodic task and all
aperiodic jobs)
Determine the response time of A1
Determine the worst case response time of all
periodic tasks
Is the system schedulable?
T={ (5, 1.5), (7, 2) }
TDS = ( 4, 1) , A = {(0.5, 2.5), (2.5, 0.25)}
7/21/2015
Dr Alain Beaulieu
Exercise Solution
draw the schedule for the system below
T={ (5, 1.5), (7, 2) }
TDS = ( 4, 1) , A = {(0.5, 2.5), (2.5, 0.25)}
Tasks
TDS
A1
A1
A1
A
2
T1
T2
0
7/21/2015
2
4
6
Dr Alain Beaulieu
8
t
Exercise Solution
determine the response time of A1
wA1 = 8.5 - 0.5 = 8
wA2 = 8.75 - 2.5 = 6.25
determine the worst case response time of all
periodic tasks
w11
w12
= e1 + es + (w10-es) / ps es
where w10 = 1.5
= 1.5 + 1 + (1.5 -1) / 4 (1) = 3.5
= 2.5 + (3.5 -1) / 4 (1)= 3.5
therefore w1 = 3.5 D1
7/21/2015
(worst-case)
Dr Alain Beaulieu
Exercise Solution
determine the worst case response time of all
periodic tasks (continued)
w21
w22
w23
= e2 + es + (w20-es) / ps es + (w20) / p1 e1
= 2 + 1 + (2 -1) / 4 (1) + 2 / 5 (1.5) = 5.5
= 3 + (5.5 -1) / 4 (1) + 5.5 / 5 (1.5) = 8
= 3 + (8 -1) / 4 (1) + 8/ 5 (1.5)
=8
therefore w2 = 8 > D2
w20 = 2
(worst-case)
is the system schedulable?
No since all tasks do not meet their deadlines under worst-case
conditions, we can not guarantee the system schedulable
7/21/2015
Dr Alain Beaulieu
References
[1] Liu, J.W.S., “Real-Time Systems”, Prentice-Hall, 2000.
[2] Burns, A. and Wellings, A., “Real-Time Systems and
Programming Languages”, Chapter 13, Addison Wesley,
1997
[3] TimeSys Corp, “The Concise Handbook of Real-Time
Systems”, Version 1.0, 1999
7/21/2015
Dr Alain Beaulieu