資工系網媒所NEWS實驗室 P

Download Report

Transcript 資工系網媒所NEWS實驗室 P

Paper Discussion
C. L. Liu and James W. Layland, "Scheduling
Algorithms for Multiprogramming in a Hard-RealTime Environment", JACM, Vol 20, No. 1, pp. 46-61, 1973
Chihg-Chih Han, Kwei-Jay Lin and Chao-Ju Hou,
"Distance-Constrained Scheduling and Its
Applications to Real-Time Systems", IEEE Trans.
on Computers, Vol 45, No. 7, pp. 814-826 1996
1/52 資工系網媒所
NEWS實驗室
Scheduling Algorithms for Multiprogramming in
a Hard-Real-Time Environment
No non-time-critical jobs
Pure Process Control
C. L. Liu and James W. Layland, "Scheduling Algorithms for Multiprogramming
in a Hard-Real-Time Environment", JACM, Vol 20, No. 1, pp. 46--61, 1973
2/52 資工系網媒所
NEWS實驗室
Assumptions
(A1) The requests for all tasks for which hard deadlines exist are
periodic, with constant interval between requests.
(A2) Deadlines consist of run-ability constraints only--i.e, each
task must be completed before the next request for it occurs.
(A3) The tasks are independent in that requests for a certain task
do not depend on the initiation or the completion of requests
for other tasks.
(A4) Run-time for each task is constant for that task and does
not vary with time. Run-time here refers to the time which is
taken by a processor to execute the task without interruption.
(A5) Any nonperiodic tasks in the system are special; they are
initialization or failure-recovery routines; they displace periodic
tasks while they themselves are being run, and do not
themselves have hard, critical deadlines.
3/52 資工系網媒所
NEWS實驗室
Real-Time Task Model
Periodic Task Model
parameters are known a priori
request time
ready time
deadline start finish preempt resume
period
worst-case execution time
Predictability vs. Schedulability
high predictability and schedulability
easy-to-check schedulability condition
4/52 資工系網媒所
NEWS實驗室
Scheduling Approaches
Time-Driven Scheduling Approach
widely used
inflexible, efficient
large space needed
e.g. cyclic executive
0
3
6
Priority-Driven Scheduling Approach
dynamic-priority
e.g. earliest deadline first
fixed-priority
e.g. rate monotonic
0
3
6
5/52 資工系網媒所
NEWS實驗室
Terms in Scheduling
job: an instance of a task
deadline: next request time of the same task
overflow at time t: t is a deadline of unfulfilled request
feasible: scheduled with no overflow (schedulable)
response time: time span from request to finish
critical instance: an instance when a request will have
the largest response time
critical time zone: time interval from a critical instance
to its finish time
6/52 資工系網媒所
NEWS實驗室
A Fixed Priority Scheduling Algorithm
THEOREM 1. A critical instant for any task occurs
whenever the task is requested simultaneously with
requests for all higher priority tasks.
A scheduling algorithm is feasible if all tasks can
be fulfilled at their critical instants.
7/52 資工系網媒所
NEWS實驗室
A Fixed Priority Scheduling
Algorithm (cont.)
THEOREM 2. If a feasible priority assignment
exists for some task set, the rate-monotonic priority
assignment is feasible for that task set.
8/52 資工系網媒所
NEWS實驗室
Optimality
THEOREM 2. If a feasible priority assignment
exists for some task set, the rate-monotonic priority
assignment is feasible for that task set.
9/52 資工系網媒所
NEWS實驗室
A Fixed Priority Scheduling
Algorithm (cont.)
THEOREM 3. For a set of two tasks with fixed
priority assignment, the least upper bound to the
processor utilization factor is U = 2 (2 ½ - 1).
case 1
T1
T2
case 2
T1
T2
10/52 資工系網媒所
NEWS實驗室
A Fixed Priority Scheduling
Algorithm (cont.)
The minimum U occurs at the boundary of two cases
T1
T2
T1
T2
11/52 資工系網媒所
NEWS實驗室
Least Upper Bound
An easy-to-check schedulability condition
m
U   (Ci / Ti )
i 1
1
1/ m
m(2
 1)
n=2, 0.83
n=3, 0.78
n=, 0.69
12/52 資工系網媒所
NEWS實驗室
A Fixed Priority Scheduling
Algorithm (cont.)
THEOREM 4. For a set of m tasks with fixed priority
order, and the restriction that the ratio between any two
request periods is less than 2, the least upper bound to
the processor utilization factor is U = m(2 1/m - 1).
find optimal conditions
when optimality exists
or if it is optimal and condition A does not hold
conflicts, so A must be true.
solve equations at optimal condition
derive bound
relax assumption
13/52 資工系網媒所
NEWS實驗室
T1
T2
T1
T2
T1
T2
T1
T2
14/52 資工系網媒所
NEWS實驗室
15/52 資工系網媒所
NEWS實驗室
A Fixed Priority Scheduling
Algorithm (cont.)
THEOREM 5. For a set of m tasks with fixed priority
order, the least upper bound to processor utilization is
U = m(2 1/m - 1).
The bound of special case is tighter than general case.
Rate Monotonic Priority Assignment
The smaller the period, the higher the priority.
Rate Monotonic Scheduling Algorithm
generate the whole schedule
on-line
off-line
priority queue
100%?
16/52 資工系網媒所
NEWS實驗室
A Deadline Driven Scheduling Algorithm
THEOREM 6. When the deadline driven scheduling
algorithm is used to schedule a set of tasks on a processor,
there is no processor idle time prior to an overflow.
17/52 資工系網媒所
NEWS實驗室
A Deadline-Driven Scheduling
Algorithm (cont.)
THEOREM 7. For a given set of m tasks, the deadline
driven scheduling algorithm is feasible if and only if U  1.
necessary condition (only if)
if feasible, the computation demand  processor time
sufficient condition
if U  1,
and not feasible
case 1
0 T T1 T2…Tm
all bi beyond T
18/52 資工系網媒所
NEWS實驗室
Sufficient Condition (cont.)
case 2
some bi were carried out before T
19/52 資工系網媒所
NEWS實驗室
A mixed Scheduling Algorithm
?
20/52 資工系網媒所
NEWS實驗室
Distance-Constrained Task Model
video server
inter-frame distance must be less than 33ms
robot arm movement
needs steady and smooth operations
satellite/cellular phone tracking
service in constant time interval
more predictable inter-execution time than
the periodic task(PT) model
worst inter-execution time for PT is 2xperiod-ei
Chihg-Chih Han, Kwei-Jay Lin and Chao-Ju Hou, "Distance-Constrained Scheduling and Its
Applications to Real-Time Systems", IEEE Trans. on Computers, Vol 45, No. 7, pp. 814-826, 1996
21
資工系網媒所
NEWS實驗室
Pinwheel Problem
Given a multiset A={a1, a2, ... ,an}, ai 
Find an infinite sequence of symbols from
{1, 2, ... , n} such that at least one symbol i
within any interval of ai symbols
A={2,3}  2 2  2 ...
 2  2 ...
A unit-time schedule
22/52 資工系網媒所
NEWS實驗室
Pinwheel Schedule
12
0
11
10
9
T4
T1
7
T1
2
T2
T2
8
1
T3
3
4
5
6
Pinwheel schedule
6666666
T1 (1,6)
T2 (3,6)
T3 (2,12)
T4 (2,12)
0 1 2 3 4 5 6 7 8 9 10 11 12
23/52 資工系網媒所
NEWS實驗室
Pinwheel Transformation
2
E.g. A={3,4,6,13} {3} B={3,3,6,12} ={3,3,3×21, 3×22}
• single-number reduction
Pinwheel
A
any numbers  multiples
jitterless, predictable
(RM)
Signal
analog  digital
noiseless, ease of
control
e.g. CD music
B
(PW)
0
3
6
9
12
24/52 資工系網媒所
NEWS實驗室
Pinwheel Scheduling Properties
Good jitter control in schedules
Easy-to-check schedulability
Predictable resource accesses
Easy extension for aperiodic tasks
Predictable end-to-end delay
Network scheduling (INFOCOM’95 by Han & Shin)
Flexible time-driven approach
25/52 資工系網媒所
NEWS實驗室
Pinwheel Scheduler
Given a multi-set of distance constraints of n tasks
A={a1, a2, ... ,an}, density r(A)Si (1/ai )
Find another B={b1, b2, ... ,bn}, "i, bi ai ,
A is schedulable if B is schedulable.
If bi’s are multiples (bi|bj) and r(B)1,
B is schedulable.
E.g. A={3,4,6,7} (specialized) B={3,3,6,6}
schedule is “1 2 3 1 2 4 1 2 3 1 2 4 ...”
The goal is to minimize density increase
26/52 資工系網媒所
NEWS實驗室
Previous Works
CX: the set of all instances schedulable by Scheduler x
dX: the schedulable density bound for Scheduler x
CSx
CS23
CSa
CSbc
Sa:x=a1 ,
dSa 0.5
Sx: a1 /2 <x  a1 ,
dSx 0.65
S23:use 2 and 3,
dS23 20.58
Sbc: b=a1 , b c < 2b
dSbc 230.6
27
資工系網媒所
NEWS實驗室
Single-node Pinwheel Scheduling
Earlier work: use a base of 2 , find x in (a1/2 ,a1]
Sa, Sx, Sbc, Sby, Sxy: 0.5, 0.65, 2/3, …
distance constraints of integer, unit execution time
Sr: use a base of 2 , find r in (a1/2 ,a1]
real-number distance constraints and execution times
Our contributions:
Srg: use a base of g
Srb: try all bases (optimal for single-number reduction)
HSr: near-optimal polynomial-time heuristic
Integer Pinwheel Scheduling: Sxg, Sxb , HSx
28/52 資工系網媒所
NEWS實驗室
Various Pinwheel Schedulers
distance
near optimal
g=2 optimal g
constraint
heuristic
x is an
integer
Sx
Sxb
HSx
r is a real
number
Sr
Srb
HSr
29/52 資工系網媒所
NEWS實驗室
Multiple-Node Scheduling
All nodes are specialized with the same base
using DSr (Distributed Sr Scheduling)
Pinwheel phase alignment
Minimize the total end-to-end delay
Minimize the maximum end-to-end delay
Nodej
N1
N2
...
Nm
...
Pinwheelj
Pinwheel1
Pinwheel2
...
Pinwheelm
30/52 資工系網媒所
NEWS實驗室
Relationships of Pinwheel Schedulers
CX: the set of all instances schedulable by Scheduler x
CSr
c.
f.
CSrb
e.
CSx
a.
CSxb
b.
d.
a = {(1,2),(1,3)}
b = {(1,2.1),(2.1,6)}
c = {(1,1.9),(1,4)}
d = {(1,2),(2.1,6)}
e = {(1,1.9),(2.1,6)}
f = {(1,2),(1.1,3)}
: Jitterless
31/52 資工系網媒所
NEWS實驗室
Synchronous Scheduling
Intranode: pinwheel scheduling makes task executions
regular and predictable, i.e. no jitter.
Internode: in all nodes, transform the periods of all tasks to
harmonic numbers so that tasks of the same period are
synchronized.
The worst case delay for a task between its arrival and the
beginning of its execution on a node is one period.
Nodej
N1
N2
...
Nm
...
32/52 資工系網媒所
NEWS實驗室
33/52 資工系網媒所
NEWS實驗室
34/52 資工系網媒所
NEWS實驗室
Simplification
35/52 資工系網媒所
NEWS實驗室
Study of Pinwheel Scheduling
n tasks are schedulable on a node (using HSr)
1/n
if the total utilization is  n (2 - 1).
n tasks are schedulable on all nodes (using DSr)
1/n-1
if the utilization on any node is 2
.
Algorithm of O(n log n + nl) to minimize the total or
maximum task delay between two nodes with l different
periods.
Algorithm of O(mn log n + mnl) to minimize the total end-toend delay on m nodes.
Polynomial heuristics to reduce the maximum end-to-end
delay on m nodes.
36/52 資工系網媒所
NEWS實驗室
Time-driven Scheduling Approach
Off-line
construct complete schedule
exponential time and space
generate effective time parameters
start time, resume time, finish time
optimization
On-line
0
3
execute tasks according
to off-line
generated schedule or parameters,
inflexible
6
37/52 資工系網媒所
NEWS實驗室
SSr: Pinwheel Schedule Constructor
Generate start times and finish times in O(n2)
0
5.3
10.6
15.9
21.2
task1
task2
task3
task4
task5
38/52 資工系網媒所
NEWS實驗室
Time-Driven Pinwheel Scheduling
Generate effective pinwheel schedule.
Generate start times and finish times using SSr
Next resume time can be found in O(n)
the latest finish time of the preempting tasks
task1
task2
task3
task4
Use an on-line scheduler to schedule tasks
according to the effect schedule.
39/52 資工系網媒所
NEWS實驗室
TOPS:Time-driven On-line Pinwheel Scheduler
scheduler
TOPS-c TOPS-l TOPS-f TOPS-m
(constant) (linear) (flexible)
(mix)
S,F,
S*,F*,R*
S,F
priority
off-line
generates
on-line
generates
on-line time
O(1)
complexity
space
O(bn/b1)
complexity
*S:start
R
S,F,R
O(n)
O(n)**
O(log n)
O(n)
O(n)
O(n)
time, F:finish time, R:resume time; * * amortized
40/52 資工系網媒所
NEWS實驗室
Pinwheel Transformation
Sr: d ={(1,2),(2.1,6)} {(1,2),(2.1,4)}
overflow
Sxb: d ={(1,2),(2.1,6)} {(1,2),(2.1,6)}
0
2
4
6
8
41/52 資工系網媒所
NEWS實驗室
Relationship between CSrb, PRM , and PEDF
PX: the set of all periodic task sets schedulable by Scheduler x
CX: the set of all DCTS’s schedulable by Scheduler x
PEDF
PRM
a = {(1,2),(1,3)}
b = {(1,2),(0.5,3),(1,7)}
c = {(1,2),(1,3),(1,7)}
d = {(1,2),(1.1,3)}
e = {(1,2),(2,3)}
e.
d.
c.
CSrb
b.
n  2 a.
PRM = CSrb
42
資工系網媒所
/52
NEWS實驗室
Relationships of Schedulers
CX: the set of all instances schedulable by Scheduler x
g.
CRM
CSrb
CSr
c.
f.
e.
CSx
CSxb
a.
b. d.
a = {(1,2),(1,3)}
b = {(1,2.1),(2.1,6)}
c = {(1,1.9),(1,4)}
d = {(1,2),(2.1,6)}
e = {(1,1.9),(2.1,6)}
f = {(1,2),(1,3),(1,7)}
g = {(1,2),(1.1,3)}
: Jitterless
43/52 資工系網媒所
NEWS實驗室
Examples of Schedulers
a = {(1,2),(1,3)}, r0.83
CRM
[Sx] {(1,2),(1,2)}, F
b = {(1,2.1),(2.1,6)}, r0.83
CSrb
[Sx] {(1,2),(2.1,4)}, F.03
[Sr] {(1,2.1),(2.1,4.2)}, F0.98
[Sxb] {(1,2),(2.1,6)} , F0.85
CSx
CSr
c.
a.
b.
CSxb
c = {(1,1.9),(1,4)}, r0.8
[Sr] {(1,1.9),(1,3.8)} , F0.9
[Sxb] {(1,1),(1,4)} , F.25
d.
d = {(1,2),(2.1,6)}, r0.85
[Sr] {(1,1.5),(2.1,6)}, F .02
[Sxb] {(1,2),(2.1,6)}, F0.85
44
資工系網媒所
NEWS實驗室
More Examples of Schedulers
e = {(1,1.9),(2.1,6)}, r0.88
CSx
CSr
CSrb
CRM
[Sr] {(1,1.5),(2.1,6)},
F.02
[Sxb] {(1,1),(2.1,6)},
F.35
[Srb] {(1,1.9),(2.1,5.7)},
F0.89
CSxb
f = {(1,2),(1,3),(1,7)}, r0.9
[Srb] {(1,2),(1,2),(1,6)},
F.
e.
f.
g.
g = {(1,2),(1.1,3)}, r0.8
45/52 資工系網媒所
NEWS實驗室
Comparison of Schedulers
Scheduler
EDF
RM
Srb
schedulability
condition
jitter
high
low*
none
end-to-end delay
long
short
shortest
easy*
easy
large
small
stable
stable
1
resource reservation difficult
worst case
large
blocking time
system
unstable
overload
n (21/n - 1) n (21/n - 1)
*for higher priority tasks
46/52 資工系網媒所
NEWS實驗室
Priority Inversion
47/52 資工系網媒所
NEWS實驗室
Priority Inheritance
48/52 資工系網媒所
NEWS實驗室
Priority Inheritance (cont.)
m lower priority task access k distinct semaphores
A job can be blocked at most min(m,k) critical
sections
Might have deadlocks
Chain of blocking
J1 access S1, S2 held by J2, J3
49/52 資工系網媒所
NEWS實驗室
Priority Ceiling Protocol
Inherit the Priority Ceiling of a semaphore
Priority Ceiling of a semaphore S
The highest priority of the jobs may lock S.
Zi,j,k is the kth critical section in Ji guarded by Sj
Idea came from:
When J1 preempts Z2,1, the priority of J1 will be strictly
higher than the priorities of all the preempted critical
sections, otherwise J1 is blocked and J2 inherits J1’s
priority.
A job can be blocked for at most one duration of one
critical section.
" i, 1 i n, C1/T1+C2/T2+…+Ci/Ti+Bi/Ti  i(21/i-1)
50/52 資工系網媒所
NEWS實驗室
Example 2
J0
J1
J2
0 1 2 3 4 5 6 7 8 9 1011121314 15
51/52 資工系網媒所
NEWS實驗室
Multiprocessor PCP
Static binding vs. dynamic binding
(m  1) 21 , 11
Global semaphore vs. local semaphore
Global critical section vs. local semaphore
Remote blocking
52
資工系網媒所
/52
NEWS實驗室
53/52 資工系網媒所
NEWS實驗室
54/52 資工系網媒所
NEWS實驗室