Basic Real-time Scheduling Techniques Ppt
-
Upload
sukhchain-singh -
Category
Documents
-
view
220 -
download
3
Transcript of Basic Real-time Scheduling Techniques Ppt
1
Basic Real-Time Scheduling Techniques
Department of Computer Science & EngineeringUniversity of South Carolina
Spring, 2007
What
• Decide when and where to execute tasks such that– Timing requirements are met– Performance/resource usage is optimized
2
• Scheduling analysis– Study the properties of scheduling
policies• Can a task set meet the timing requirement
with certain given scheduling policies?• Scheduling synthesis
– For a given task set, what scheduling algorithm produce a feasible schedule?
• Feasible schedule– meet each task’s deadline without violating any
constraints• Optimal schedule
– Optimality criteria: an optimality criterion assesses the relative merits of competing feasible schedules
– Optimal schedule may not be unique
3
Scheduling Policy Taxonomy • Uniprocessor/Multiprocessor• Static/dynamic (offline/on-line)• Periodic/aperiodic• Priority driven/Non-priority driven• Preemptive/Non-preemptive• Hard real-time/soft real-time• Homogeneous/heterogeneous multiprocessors• Tasks with precedence constraints/independent tasks• Scheduling with other constraints (power, fault tolerance,
synchronization, resource constraints, and other quality-of-service constraints)
Two most important priority-driven preemptive scheduling schemes
• Rate Monotonic Scheduling (RMS)• Earliest Deadline First (EDF)
4
Rate Monotonic Scheduling
• C. Liu and J. Layland. Scheduling Algorithms for Multiprogramming in a Hard Real-Time Environment. Journal of the ACM, 20(1), pages 46-61, Jan. 1973
• Rate Monotonic Analysis (RMA)
Model
• All the tasks run on the single processor• No data dependency between tasks• No context switch penalty• Priority driven preemptive scheduling
5
Model (Cont’d)
• Tasks– Period ( Ti )
• Constant interval between the arrivals of two task consecutive jobs
– job
– Deadline ( Di )• Assume Di = Ti
– Worst Case Execution Time ( Ci ) – Initial arrival time ( Ri )
• Assume R0 = R1 = … = Rn = 0 (The first job of all the tasks arrive at the same time)
What is RMS
• Assign priorities according to their periods (rates)– The longer the period, the lower the priority
6
Example
Τ1=D1=4 C1=1T2=D2=6 C2=2T3=D3=11 D3=4
4 8 12
6 12
110
More about RMS
• Critical instant– At which if a task arrives, it will have the
longest response time• Theorem:
– A critical instant for a task occurs whenever the task is released simultaneously with all higher priority tasks.
7
More about RMS (Cont’d)
• RMS is optimal – Theorem: If a feasible fixed priority assignment
exists for a task set, the RM priority assignment is also feasible for that task set.
Exact Timing Analysis for Fixed Priority Scheduling
• J.P. Lehoczky, L. Sha and Y. Ding. The Rate Monotonic Scheduling Algorithm: Exact Characterization and Average Case Behavior. Proceedings of IEEE Real-Time Systems Symposium, pages 166-171, Dec. 1989.
• What is the exact worst case response time for each task?
8
The Worst Case Response Time• For task i, within interval [0,t], the computation
requirement is
• If Wi(t) <= t, task i can be finished before t.
∑= ⎥
⎥⎥
⎤
⎢⎢⎢
⎡=
i
j jji T
tCtW1
)(
Τ1=D1=4 C1=1T2=D2=6 C2=2T3=D3=11 D3=4
4 8 12
6 12
110
Schedulability Analysis
• Solving Wi(t) = t , we can get the exact value of t and Wi(t), which is the worst case response time for task i– Fixed point iteration with initial value of t=0
• Task i is schedulable if t <= Ti. • Or, equivalently
– Task i is schedulable if there is a 0 < t <= Ti such that Wi(t) <= t (or Wi(t)/t <= 1)
9
Schedulability Analysis
• If all tasks can finish before their deadlines, the task set is feasible. – Let
• Li(t) = Wi(t)/t• Li = mint Li(t), 0<t <=Ti• L = max Li, 1 <= i <= n
– Then, • Task i is schedulable if Li <= 1• The entire task set is feasible if L <= 1.
Schedulability Analysis
• To test if Wi(t’) <= t’ for some 0 <= t’ <= Ti , we don’t have to test an infinite number of data points
• Wi(t’) <= t’ for some 0 <= t’ <= Ti iff Wi(t) <= t for at least one of the following
– Scheduling points
},...,1;,...,1|{ ⎥⎦⎥
⎢⎣⎢===
j
ij T
TkijkTt
∑= ⎥
⎥⎥
⎤
⎢⎢⎢
⎡=
i
j jji T
tCtW1
)(
10
Example
• Task set– T1 = 100, C1 = 40– T2 = 150, C2 = 40– T3 = 350, C3 = 100
• Is it schedulable? – Test scheduling points – Fixed point iteration
Utilization Bound
• Utilization
• Theorem: For a set of m tasks with fixed priority assignment, the least upper bound to processor utilization is
• E.g. m=2, U=0.83; m= 3, U=0.78; for large m, U ln2=0.69
∑=i i
i
TCU
)12(1
−= mmU
11
Utilization Bound (Cont’d)
• A sufficient condition – The task set is feasible as long as its utilization is no larger than the
utilization bound– Many feasible task can have higher utilization
• Many feasible fixed-priority task sets cannot 100% utilize the processor
Improving Utilization Bound• Liu and Layland
• Burch’s Bound – A. Burchard, J. Liebeherr, Y.Oh and S.H. Son, “New strategies
for assigning real-time tasks to multiprocessor systems”, IEEE Trans. On Computers, v. 44, no. 12, pp 1429-1442, 1995
– Theorem: Given a real-time task set τ1 , τ2, .... , τk . Define
then the task is schedulable on one processor with RM algorithm if
(a) β < 1−1/Κ and
(b) β >=1−1/Κ and
⎣ ⎦ iKi
iKi
iii SSandKiTTS minmax11
22 ,...,2,1loglog≤≤≤≤
−==−= β
)12(1
−= mmU
12)12)(1( 1)1/( −+−−≤ −− ββ KKU
)12( /1 −≤ KKU
12
Improving Utilization Bound Using Linear Programming
• D. Park. S. Natarajan and A. Kanevsky, “Fixed-priority scheduling of real-time systems using utilization bounds”, Journal of System Software, v. 33, pp. 57-63, 1996
• How to “improve” the bound ?– For some specific set of problems– For example, when designing a real-time embedded system
• Periods and deadlines of the tasks are generally known already (constants)
• Execution time depends on the implementation details (variables)– Architecture type– Processor type– Cache size, memory organization, etc
• How to get a better bound with the given periods and deadlines ?
Improving Utilization Bound Using Linear Programming
• Exact timing analysis for fixed-priority scheduling
• Using a set of bounds– Define:
– Bi is called the utilization bound for τi
• τi will meet its deadline as long as Ui is no more than Bi
∑=i
j
j
TC
U=j 1
i
13
Linear Program Formulation (Assuming Di < Ti)
Min:
S.t.:
∑=
≥⎥⎥⎥
⎤
⎢⎢⎢
⎡i
jk
j
kj pT
TpTC
1⎥⎦⎥
⎢⎣⎢=
k
iT
Dp ,,2,1 …
1,,2,1 −= ik …
∑=
≥⎥⎥⎥
⎤
⎢⎢⎢
⎡i
ji
j
ij D
TDC
1
∑=i
j
j
TC
U=j 1
i
Earliest Deadline First (EDF) Scheduling
• What– The task with the closest deadline is assigned
the highest priority– Theorem: A given task set is feasible by EDF
iff U <=1.
14
Earliest Deadline First (EDF) Scheduling (Cont’d)
• Can fully utilize the processor
• Dynamic priority assignment– Need to recompute and assign the priority
Revisit the model
• All the tasks run on the single processor• No data dependency between tasks• No context switch penalty• Priority driven preemptive scheduling• Di = Ti• Ri = 0
15
Fixed Priority Scheduling (Di<Ti)
• RMS is not optimal anymore for real-time system with Di < Ti , R1=R2=…=Rk
• Example τ1: R1=0 C1=1 D1= 2 T1=2
τ2: R2=0 C2=1 D2= 1 T2=3
Fixed Priority Scheduling (Di<Ti)
• Deadline Monotonic Scheduling (DMS)– Assign priorities based on (relative) deadline.
The smaller the deadline, the higher the priority.– An optimal priority assignment for fixed-priority
scheduling for one processor
• N. C. Audsley, "Deadline Monotonic Scheduling", YCS 146, Department of Computer Science, University of York (October 1990). http://citeseer.ist.psu.edu/audsley90deadline.html
16
Deadline Monotonic Scheduling • Critical point• Exact timing analysis
– Task τi is schedulable iff there exist 0 < t <= Di such that Wi(t) <= t
– Wi(t’) <= t’ for some 0 <= t’ <= Di iff for Wi(t) <= t such that t is at least one of the following scheduling points
• Computational complexity• Pseudo-polynomial O(max(Di))
∑= ⎥
⎥⎥
⎤
⎢⎢⎢
⎡=
i
j jji T
tCtW1
)(
},...,1;1,...,1|{ ⎥⎦⎥
⎢⎣⎢=−==
j
iji T
DkijkTorDt
Fixed Priority Scheduling with Arbitrary Starting Times
• Optimality – Deadline Monotonic Scheme is not optimal anymore– Example 1:
τ1: R1=1 C1=1 D1= 1.5 T1=2
τ2: R2=0 C2=1.5 D2= 2 T2=4 (τ2 > τ1 can be schedulable)
Example 2: τ1: R1=10 C1=1 D1= T1=12
τ2: R2=0 C2=6 D2= T2=12
τ3: R3=0 C2=3 D2= T2=8 (τ3 > τ2 > τ1 can be schedulable)
17
Fixed Priority Scheduling with Arbitrary Starting Time
• Complexity– Theorem: Given a real-time system R with arbitrary starting times
and a fixed priority assignment p, the problem to decide whether or not the schedule produced by p is feasible is NP-hard
• Two special cases– Deadline monotonic assignment is optimal for
• Two task systems with Di=Ti, i = 1, 2.• Task set with Di=Ti, i = 1, …, n and Ti is an integral multiple of Tj if
Ti > Tj i.e., the harmonic task set
Real-Time System with Different Arrival Time
• Schedulability Analysis– Sufficient Condition
• If the task set is schedulable assuming that all the tasks start at the same time, then the original task set is also schedulable.
• Theorem: Let Rm = max (R1,R2,…,Rn), and L = LCM(T1,T2,…,Tn), then the task set is schedulabe iffthe all the jobs within (Rm, Rm+2L] can meet their deadlines.
18
EDF Scheduling with Di < Ti and Arbitrary Starting Times
• The optimal scheduling
• Theorem: Any sequence that at any instant schedules the job with the earliest deadline among all the eligible jobs is optimal with respect to minimizing maximum lateness
EDF Scheduling with Di < Ti and Arbitrary Starting Times
• Utilization
• Is U <= 1 necessary and sufficient ?
• How about
∑=i i
i
TCU
∑ ≤i i
i
DC 1
19
EDF Feasibility Analysis
• Reference– Zheng Qin, K. G. Shin, On the ability of
establishing real-time channels in point-to-pointpacket-switched networks, IEEE Transactions on Communications, vol 42, No. 234, pp 1096-1105, 1994.
EDF Feasibility Analysis
• Theorem: A task set T = (τ1, τ2, .., τn), is EDF-schedulable iff– For any t > 0, ∑i Wi(0,t) <= t, i = 1, …, n– where Wi(0, t) is the total workload from the jobs of
τi that arrive before t and must finish by t, i.e.,
while
j
i
j j
ii C
TDttW
+
=∑
⎥⎥⎥
⎤
⎢⎢⎢
⎡ −=
1)(
⎡ ⎤ ⎣ ⎦xx +=+ 1
20
EDF Feasibility Analysis
• The above theorem requires to check infinite number of points
• In fact, only limited number of point testing is necessary (see the above reference for details)
Summary• Scheduling techniques can be classified along many
dimensions• RMS and EDF are two most important uniprocessor,
priority-based, preemptive scheduling policies• RMS (DMS)
– The optimal fixed priority assignment– Feasibility analysis
• Exact timing analysis• Utilization bound
• EDF– The optimal scheduling algorithm– Feasibility analysis
• Utilization bound• Work demand analysis