Professional Documents
Culture Documents
Jfair: A Scheduling Algorithm To Stabilize Control Applications
Jfair: A Scheduling Algorithm To Stabilize Control Applications
Jfair: A Scheduling Algorithm To Stabilize Control Applications
63
(1)
ei (t) =
1
0
if i is executing at time t,
otherwise.
i (t) = ui t
t
0
ei (x) dx.
(2)
i (t2 ) = ui t2
t2
0
ei (x) dx
= ui t1 + ui (t2 t1 )
= i (t1 ) + ui (t2 t1 )
t1
0
t2
t1
ei (x) dx
t2
t1
ei (x) dx
ei (x) dx.
(3)
t 0,
i = 1, . . . , n.
The relation between the jitter and the lag will be claried
in the following. Assuming that lag i (t2 ) for task i is
within the lag limits at time t2 we obtain,
|i (t2 )| i ,
|i (t1 ) + ui (t2 t1 ) k ci | i ,
k ci i (t1 ) + i
k ci i (t1 ) i
t2 t1
,
ui
ui
k ci i (t1 ) i
k ci i (t1 ) + i
t1 +
t 2 t1 +
,
ui
ui
64
10
15
20
(a) Pfair
10
15
20
(c) Jfair
Figure 1.
20
10
15
20
Example: three tasks with execution times ci = 5, periods h1 = 10, h2 = h3 = 20, lag limits |i (t)| 1.
i
Ji 2 .
ui
(4)
hi
(7)
Ji
(5)
ui .
2
where the maximum amount of jitter which task i can
tolerate is Ji .
We shall also dene the notion of pending work i (t) for
a periodic task i at t,
|i (t)| i =
t
t
+ 1 ci
ei (x) dx.
hi
0
n
mi
i=1
This indicates that the limit on the output jitter for task
i translates into a constraint on lag,
15
i (t) =
10
(b) Server-based
(6)
65
Table I
S UMMARY OF THE CHARACTERISTICS OF THE SCHEDULE .
policy
Pfair
Server
Jfair
Improved Jfair
preemption density
1.0
1.2
0.7
0.5
lag limit
1
1
1
1
B. Theoretical guarantees
A. Scheduling policy
A job of task i has execution time ci and period hi .
Our proposed algorithm divides each job into several smaller
subjobs, for each of which the execution time and articial
deadline at time t are denoted by ci (t) and di (t), respectively. In fact, our objective is to assign the execution times
ci (t) and deadlines di (t) in such a way that the lag limits
are not violated.
The scheduling policy is as follows,
The scheduler is activated at the subjobs deadlines (and
at time 0) and when a subjob nishes its execution.
The scheduler is an EDF-based scheduler, i.e., the subjob with the earliest deadline has the highest priority.
The new deadlines and execution times of each subjob
are assigned at its own old deadlines (and at time 0).
The deadlines di (t) of the subjobs are set according to
Equation (11). In the case where i (t) < di (t) ui , the
.
deadline is modied to di (t) = ui (t)
i
The subjobs execution time at time t is assigned to be
ci (t) = di (t) ui .
To have a better understanding of the algorithm, let us
rst have a closer look at how our simple scheduling policy
works. Intuitively, the scheduler breaks a job into several
quasi-periodic subjobs.
Starting with i (0) = 0, the deadline and execution-time
i
i
are di (0) = ui (1u
and ci (0) = 1u
, respectively. At
i)
i
t2
t1
ei (x) dx,
(8)
i = i (t1 ) + ui (t2 t1 ),
(9)
i i (t1 )
.
ui
(10)
66
3) Scheduling properties
It should now be clear that the lag limits will not be
violated as long as the subjob execution-time ci (t) ci (t)
and the deadlines di (t) are met. The next theorem
nguarantees
that all lag limits will be respected, provided i=1 ui 1.
Theorem 1: Given a periodic taskset and the positive and
independent lag limits for each task, there exists a scheduling
policy that respects the lag limits, iff the utilization of
the taskset does not exceed one. The Jfair algorithm is an
instance of such a scheduling policy.
Proof: We shall rst focus on the proof of the if part. It
has been shown that the lag constraints are satised as long
as all tasks scheduled satisfy ci (t) ci (t) and all deadlines
di (t) are met. It has been shown, in the previous subsection,
that the former property is satised by itself under Jfair
policy. The latter is proved by contradiction in the following,
for the proposed policy.
Let us assume
n that we have the rst deadline miss at time
t1 , while i=1 ui 1. Let us further consider the longest
contiguous busy interval before time t1 where all the subjobs
executed in the interval of [t0 , t1 ] should have their release
times (or activation times) and deadlines in this interval. Let
us denote the start time of this interval by t0 and its length
by l = t1 t0 . Since we considered the longest contiguous
busy interval ending at t1 , just before time t0 , the resource
is not processing subjobs with deadlines less than or equal
to t1 . This means that t0 should be the release time (or
activation time) of a subjob with deadline before t1 . Since
the assigned execution times in Jfair are computed based on
ci (t) = di (t) ui , the demand of each task i in this interval,
denoted by xi , is less than or equal to l ui , i.e., l ui xi .
Taking all tasks (with both activation and
in this
deadline
interval) into consideration, we obtain i l ui i xi .
Having a
deadline miss
1 indicates that
i xi >
at time t
l.
From
l
x
and
x
>
l,
we
conclude
i
i
i
i
i
in
i l ui > l. This indicates that
i=1 ui > 1, which is a
contradiction.
The only if part is simply because no taskset with
utilization above one is schedulable (the deadlines will be
violated).
The next theorem discusses the number of preemptions when using Jfair algorithm, compared to the optimal
scheduling policy. We assume that each job experiences one
preemption when it nishes.
Theorem 2: The number of preemptions by the proposed
scheduling policy is at most three times the number of
preemptions by any feasible schedule under the given lag
limits.
Proof: First, we shall nd a lower bound on the number
of preemptions experienced by task i in one period hi ,
considering any feasible scheduling policy. Note that the
set of feasible scheduling policies includes also the optimal
scheduling policy, where the optimality is dened in terms
of number of preemptions.
The proof is based on the observation that an upper
bound on the maximum possible contiguous execution time,
denoted by x, for each task can be computed. The upper
ui (1 ui )
ui
di (t) =
(11)
i
where we have considered the execution time ci (t) = 1u
.
i
Note that the resource allocated in the interval of [0, t+di (t)]
is ui (t + di (t)).
If a subjob of task i does not violate its deadline di (t),
the lag constraint i (t) i will not be violated before its
deadline. In other words, as long as the deadlines are met,
the lag will not exceed the upper limit, i.e., i (t) i .
(12)
This indicates that the lower lag limits will not be violated,
as long as
(13)
ci (t) ci (t).
Note that t is the instant at which the execution of the subjob
is assigned to it by the scheduler.
In our scheduling policy we want to enforce ci (t) ci (t)
and ci (t) = di (t) ui , which leads to,
ci (t) = min {ci (t), di (t) ui } .
(14)
Substituting ci (t) from Equation (12) and di (t) from Equation (11) in the above equation, we have,
i
i
i (t)
ci (t) = min
+
,
i (t) , (15)
1 ui
1 ui 1 ui
which obtains its maximum when i (t) = 0.
In general, the longer the subjobs, the fewer the number
of subjobs and the number of preemptions. Therefore, the
special case of i (t) = 0 is used in our algorithm by
carefully choosing the instant t at which the deadlines and
execution times are assigned. This leads to a quasi-periodic
i
and
pattern for subjobs with deadline di (t) = ui (1u
i)
execution time ci (t) = di (t) ui . Since i (t) = 0, the
execution time satises Equation (13). The last subjob might
have a shorter deadline, and accordingly shorter execution
time, and therefore, also satises Equation (13).
To sum up, the condition in Equation (13) is satised, and
there is no need to be considered explicitly.
67
x=
2 i
.
1 ui
(16)
c
w
J = R Rb = min 2 , + c .
i)
in a
for a task may not be less than cxi = ci (1u
2 i
period hi . This is a lower bound on the minimum number
of preemptions for task i in one period hi .
Secondly, let us compute the number of preemptions
caused by task i in one period hi . The proof is based on the
fact that the number of preemptions in a scheduling policy
based on EDF is not more than the number of jobs. In short,
this is due to the fact that a task is only preempted when a
job of another task is released.
We shall now discuss the number of subjobs generated by
our proposed policy for task i in one period hi . Considering
the quasi-period pattern of
ci (1ui )
+ 1.
i.e.,
i
Finally, observe that the following inequality holds for
a lower bound on the minimum number of preemptions of
task i by any algorithm (including the optimal one) and
an upper bound on the maximum number of preemptions
caused by task i in our Jfair algorithm, in one period hi ,
ci (1ui )
i
ci (1ui )
2 i
+1
3.
2 (1 )
2
c
,
s.t. min 2 , + c
max
,
(21)
(17)
Q=
,
2 (1 u)
(22)
Q=
,
1u
2
(23)
We shall now briey discuss an approach based on the resource reservation mechanism to guarantee a certain amount
of jitter. We consider the important case of periodic servers
[25][28] and further assume that for each control task there
exists a dedicated server. The periodic server provides Q
amount of time to the task associated with it, every period
P it is activated.
Given the server period P and budget Q, the linear bounds
on the best-case and worst-case response times based on the
(, ) model are [14]
c
+ ,
c
b
, c ,
R = max
(20)
R =
(18)
68
10
Responsetime jitter J
k1 h
Rb
Rw
k2 h
6
5
Li + ai Ji bi ,
2 i
ci i
+ ai
bi ,
ui
ui
b i ui c i
,
i
2 ai 1
2
1
0
Stability curves
Linear lower bounds
6
8
Nominal delay L
10
12
and the control task should be scheduled for this lag limit
in order to guarantee the stability of the plant.
It is worth noting that reducing the lag limit i of an
already stable task leads to an increase in the latency Li ,
but a decrease in the jitter Ji (see Equation (25)). This does
not lead to instability as shown in the following,
Figure 2. The stability curves generated by the Jitter Margin toolbox and
their linear lower bounds (the area below the curves is the stable area) [29].
The Jitter Margin toolbox computes the maximum tolerable response-time jitter Ji for a given latency Li . The
solid curves in Figure 2 are examples of the stability
curves generated by the Jitter Margin toolbox. Any latencyjitter combination below the stability curve is guaranteed
to be stable. The graph is generated for the plant with
transfer function s1000
2 +s and a discrete-time Linear-QuadraticGaussian (LQG) controller. The upper and lower solid
curves correspond to sampling periods 6 ms and 12 ms,
respectively.
Given a sampling period, the stability curve can safely
and efciently be approximated by a linear function of
the latency and worst-case response-time jitter. The linear
stability condition for a control application is of the form
Li + ai Ji bi , where ai 1, bi 0. The latency L is
the constant part of the delay that the control application
experiences, whereas the worst-case response-time jitter Ji
captures the varying part of the delay (see Figure 3). The
linear lower bounds, depicted by the dashed lines, on the
original curves generated by the Jitter Margin toolbox are
also shown in Figure 2.
Li + ai Ji bi ,
2 i
ci i
+ ai
bi ,
ui
ui
ci
(2 ai 1)
+
i bi ,
ui
ui
since the coefcient of the lag limit i , i.e.,
positive.
(2ai 1)
,
ui
is
Li + ai Ji bi ,
,
ui
2
ui
2 i
.
Ji =
ui
(27)
Li + ai Ji bi .
(26)
2 i
ci i
+ ai
bi ,
ui s i
ui s i
ci + (2 ai 1) i bi ui si 0.
Li =
(25)
(28)
69
min
s1 ,...,sn , 1 ,..., n
ui s i +
i=1
ci (1 ui si )
i
s.t. ci + (2 ai 1) i bi ui si 0,
(2 a 1)
c
s =
+
bu
bu
i = 1 . . . n,
s.t.
g(x) 0,
di (t) = min ci (t),
(29)
where ci (t) =
follows,
(30)
cu
bu=0
c (1 u s)
+ (2 a 1) = 0
2
c + (2 a 1) b u s = 0
c + (2 a 1)
.
bu
(33)
(34)
(35)
c
.
b
(36)
c (b c)
.
2a1
j T\{i }
{dj (t)} ,
(40)
di (t) 1
k Di (t)
uk , i (t)
(41)
, (42)
(32)
i +i (t)
1ui
min
(31)
(39)
ci (1 ui si )
1.
(38)
ui si +
i=1
ci (1 ui si )
i
ci + (2 ai 1) i bi ui si 0.
c (b c)
.
2a1
ui s i +
min f (x)
(37)
70
70
Invalid Solutions [%]
Jfair vs Server
60
50
40
30
20
10
0
50
60
70
80
90
1
0.8
Pfair
Jfair
iJfair
LB
0.6
0.4
0.2
0
2
Utilization [%]
Figure 4.
Number of Tasks
B. Number of preemptions
To evaluate the efciency of the proposed scheduling
policies in Section VI, we compare our approach against the
Pfair algorithm [15] and a theoretical lower bound. To this
end, 100 benchmarks are generated with utilization one for
number of tasks varying between 2 to 6. The lag limits are
set to one for all tasks, i.e., i = 1, since this is a limitation
of Pfair algorithm.
The metric of comparison is preemption density and the
results are shown in Figure 5. The minimal density of
preemptions then is
A. Stability
To evaluate our proposed algorithm experimentally, we
have generated 500 benchmarks with a number of control
applications from 2 to 10. The plants considered are chosen
from a database consisting of inverted pendulums, ball
and beam processes, DC servos, and harmonic oscillators
[1], [5]. Such plants are considered to be representatives
of realistic control problems and are extensively used for
experimental evaluation. The UUniFast algorithm [32] is
used to generate a set of random tasks for a given utilization.
The switching overhead is = r mini=1...n {ci }, where r
is a random variable uniformly distributed in the interval of
[0.01, 0.10].
We compare our proposed approach against a serverbased approach similar to Section IV-C. However, the approach based on the resource reservation mechanism essentially minimizes the bandwidth required for guaranteeing the stability of control applications. The experiments
are
nrepeated for several values of total task utilization
( i=1 ui ) and the results are shown in Figure 4. The metric
used
for this comparison
is the relative quality, dened as
NJfair N Server
100 , where NX is the number of benchNJfair
marks for which the approach X could nd a valid solution,
i.e., a solution for which all control applications are stable
and the systems is schedulable.
For the low task utilization, our approach outperforms
the server-based approach only in 10% of the benchmarks,
in terms of number of valid solutions. This percentage
increases to 59% for high task utilization, indicating that
in 59% of the benchmarks, our proposed Jfair approach
guarantees a stable and schedulable solution, while the
approach based on the resource reservation mechanism fails
to do so. The trend is also clearly visible, i.e., increasing the
task utilization leads to an increase in the number of invalid
solutions for the server-based approach, compared to Jfair.
n
ui (1 ui )
i=1
2 i
(43)
71
R EFERENCES
[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]
[10]
[11]
[12]
[13]
[14]
[15]
72