270 likes | 500 Views
BFair: An Optimal Scheduler for Periodic Real-Time Tasks. Hang Su The University of Texas at San Antonio http://www.cs.utsa.edu/~hsu/. September 14, 2011. Roadmap of This Talk. Introduction Task and system models Traditional scheduling algorithms
E N D
BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio http://www.cs.utsa.edu/~hsu/ September 14, 2011
Roadmap of This Talk • Introduction • Task and system models • Traditional scheduling algorithms • Performance and utilization bound comparisons • Boundary fair (Bfair) scheduler for periodic tasks • Scheduling decision at deadline boundary time of tasks • Simulation and Discussions • Reference 2
System Models • Periodic task model: task Ti : • Worst case execution time (WCET) ci • Period (relative/implicit deadline) pi • Utilization ui = ci / pi ; U = Σui is system utilization 0 2p p time WCET: c WCET: c 3
Multiprocessor Real-Time Systems • Given number of processors: m • A set of real-time tasks: Ti (ci, pi); i = 1,…n • The scheduling problem: when and where to execute which task to meet all timing constraints? • Objectives to consider • System utilization: U<= m • Scheduling overhead: scheduling decision points, preemption (context switch) points, and task migrations 4
Scheduling Algorithms on Single Processor • EDF (Earliest Deadline First) • Priority Assignment Policy: Always assign highest priority to the task with earliest deadline • Utilization upper bound : 1 • U<= 1 • Example: T1=(1, 3),T2=(3, 5) (U= 1/3+3/5=14/15) T11 T12 T12 T12 T21 0 1 2 3 4 5 6 10 time
Scheduling Algorithms on Single Processor • RMS ( rate-monotonic [1] ) C.L. Liu 73' • Utilization bound: • n(21/n-1) • Priority Assignment policy: Always assign highest priorityto the task with smallest period
Scheduling Algorithm on Single Processor • Example(RMS): T1=(1, 3),T2=(3, 5) (U= 1/3+3/5=14/15) • n(21/n-1) • 1*(21/1 - 1) = 1 (n=1 ) • 2*(21/2 – 1 ) = 2*(1.414... -1) = 0.828... (n=2) • U= 1/3+3/5=14/15 = 0.933 > 0.828 T11 T12 T12 T21 T12 T22 T31 T22 T22 T41 T32 T22 T32 T51 T32 IDLE 0 1 2 3 4 5 6 7 8 9 10 11 12 12 13 14 15
Traditional Approaches and Problems • Partitioned scheduling • A subset of tasks one processor; • problem reduced to single processor scheduling (e.g., EDF or RMS) • Semi-partitioned: most tasks have fixed assignment to processors, a few tasks may migrate between processors • better utilization • Global scheduling • Single global queue: free processor fetch next highest priority task in the queue • Global EDF and RMS low system utilization 8
Pfair: Proportional Fair Scheduler • Proportional Fair Scheduler: SanjoyMake progress fairly • Fully utilized on multiple processors • Proportional progress • Allocation for task Ti before time t: x • Allocation error: lagi = ui* t – x • Fair for task Ti at time t if | lagi | < 1 • x is eitherui* tor ui* t 9
Pfair: Proportional Fair Scheduler Variations of Pfair algorithms PD [Baruah’95] in [2] PD2 [Anderson’01] in [4][5] ER-fair [Anderson’00] in [3]
An Example 2 1 2 3 1 2 3 1 2 4 1 2 1 2 4 P1 4 3 4 4 5 4 4 4 3 5 4 3 4 3 5 P2 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 • T1=(1, 3),T2=(2, 5),T3=(2, 5),T4=(2, 3),T5=(1, 5) • m=U=wi =2, LCM = 15; • PF schedule • 15 scheduling points • 27 preemptions Deadline miss only happens at periodic boundaries ! 11
Boundary Fair: A new approach Dakai Zhu • Idea • Schedule ONLY at boundaries • Boundary time bk = a * pi , b0=0, bi < bi+1 ; • Allocate resources to tasks for the time units within two consecutive boundaries • Maintain fairness at boundary time bk (Bfair) • Ti get either ui* bk or ui* bk • Two-step allocation • Mandatory units to keep fairness • Optional units for future urgent tasks 12
The Example: Bfair Schedule 16/5 6/5 2 3/5 Demand 11 1 2 0 Mandatory 01/5 1 /5 0 3/5 pending ? Tasks T2, T3,T5are eligible for the optional unit • T1=(1, 3),T2=(2, 5),T3=(2, 5),T4=(2, 3),T5=(1, 5) At boundary time 0: allocate [0 3) T1 T2 T3 T4 T5 P1 P2 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 13
Algorithm for Bfair Scheduler • Define a set of boundaries: {b0, …, bL} • bk < bk+1; b0 = 0, bL = LCM; • k, Ti, bk is a multiple of pi; • At bk, we allocate [bk , bk+1) • Remaining work for Ti before bk • RWik = wi* bk – allocated units for Ti • Mandatory units: • mik = max{ 0, RWik + wi*(bk+1 – bk) } • Optional units if: m*(bk+1 – bk) > mik 14
Algorithm for Bfair Scheduler (cont.) • Eligible tasks • Pending work:PWik=RWik + wi*(bk+1 – bk) - mik > 0 • Not fully allocated: mik < bk+1 – bk • Dynamic priority: urgency of future • Character string: idea from P-fair [Baruah’96] • k(Ti) = sign[bk+1*wi – bk*wi – (bk+1- bk)] • (Ti, k) = k+1(Ti), …, k+s(Ti) • Minimum s such that k+s(Ti) ‘+’ • Time Factor (TF) if k+s(Ti) = ‘–’ 15
Algorithm for Bfair Scheduler (cont.) • For eligible tasks Ti and Tj • Compare (Ti, k) and (Ti, k) • Character by character: ‘+’ > ‘0’ > ‘–’ • Bigger string has higher priority • If tie and last character is ‘0’: arbitrary • If tie and last character is ‘–’ • Compare time factor (TF) • smaller time factor has higher priority • If tie again: arbitrary, e.g., smaller index • High priority tasks get one optional unit each 16
The Example: Bfair Schedule (cont.) 11 1 2 0 Mandatory 01/5 1 /5 0 3/5 pending * - -* - string * 0 0* 0 UF Optional 0 1 00 0 1 3 2 1 2 3 4 1 2 1 2 3 1 2 2 4 5 4 3 4 4 5 3 4 4 4 5 3 4 4 • T1=(1, 3),T2=(2, 5),T3=(2, 5),T4=(2, 3),T5=(1, 5) T1 T2 T3 T4 T5 Compared BF vs.PF: Scheduling Points: 7 vs.15 Preemptions: 24 vs.27 P1 P2 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17
Simulations and Discussions • Scheduling Points • Execution time at each scheduling point • Context switches • Task Migrations
Scheduling Points Comparisons Figure 4 from: Dakai Zhu, Xuan Qi*, An Optimal Boundary-Fair Scheduling Algorithm for Multiprocessor Real-Time Systems, Journal of Parallel and Distributed Systems, May 2011
Scheduling Points Comparisons(con.t) Figure 5 from: Dakai Zhu, Xuan Qi*, An Optimal Boundary-Fair Scheduling Algorithm for Multiprocessor Real-Time Systems, Journal of Parallel and Distributed Systems, May 2011
Execution time at each scheduling point Figure 6 from: Dakai Zhu, Xuan Qi*, An Optimal Boundary-Fair Scheduling Algorithm for Multiprocessor Real-Time Systems, Journal of Parallel and Distributed Systems, May 2011
Context Switches Figure 12 from: Dakai Zhu, Xuan Qi*, An Optimal Boundary-Fair Scheduling Algorithm for Multiprocessor Real-Time Systems, Journal of Parallel and Distributed Systems, May 2011
Context Switches(con.t) Figure 13 from: Dakai Zhu, Xuan Qi*, An Optimal Boundary-Fair Scheduling Algorithm for Multiprocessor Real-Time Systems, Journal of Parallel and Distributed Systems, May 2011
Task Migrations Figure 14 and 15 from: Dakai Zhu, Xuan Qi*, An Optimal Boundary-Fair Scheduling Algorithm for Multiprocessor Real-Time Systems, Journal of Parallel and Distributed Systems, May 2011
Reference C. L. Liu and James W. Layland. Scheduling algorithms for multiprogramming in a hard real-time environment. J. ACM, 20(1):46–61, 1973. S. K. Baruah, J. Gehrke, and C. G. Plaxton. Fast scheduling of periodic tasks on multiple resources. In Proc. of The International Parallel Processing Symposium, Apr. 1995. J.H. Anderson and A. Srinivasan. Early-release fair scheduling. In Proc. of the 12th Euromicro Conference on Real-Time Systems, Jun. 2000. J.H. Anderson and A. Srinivasan. Mixed pfair/erfair scheduling of asynchronous periodic tasks. In Proc. of the 13th Euromicro Conference on Real-Time Systems, Jun 2001. B. Andersson, S. Baruah, and J. Jonsson. Static-priority scheduling on multiprocessors. In Proc. of The 22th IEEE Real-Time Systems Symposium, pages 193–202, Dec. 2001