26
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

BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

Embed Size (px)

Citation preview

Page 1: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

BFair: An Optimal Scheduler for Periodic Real-Time Tasks

Hang SuThe University of Texas at San Antonio

http://www.cs.utsa.edu/~hsu/

September 14, 2011

Page 2: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

2

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

Page 3: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

3

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

pWCET: c

0 2p timeWCET: c

Page 4: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

4

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

Page 5: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

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 : 1U<= 1

Example: T1=(1, 3), T2=(3, 5) (U= 1/3+3/5=14/15)

T1

1

0 time1

T12

T12

T12

T21

2 3 4 5 6 10

Page 6: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

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 priority to the task with

smallest period

Page 7: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

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

Scheduling Algorithm on Single Processor

T11

1

T12

T12

T21

T12

2 3 4 5 6 100

T22

T22

7 8

T22

T41

9

T32T2

2

11 12

T51

T32

12 13

T32

14 15

IDLET31

Page 8: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

8

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

Page 9: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

9

Pfair: Proportional Fair Scheduler

Proportional Fair Scheduler: Sanjoy Make 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 either ui* t or ui* t

Page 10: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

Variations of Pfair algorithmsPD [Baruah’95] in [2]

PD2 [Anderson’01] in [4][5]

ER-fair [Anderson’00] in [3]

Pfair: Proportional Fair Scheduler

Page 11: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

11

An Example 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 !

2 1 2 3 1 2 3 1 2 4 1 2 1 2 4

4 3 4 4 5 4 4 4 3 5 4 3 4 3 5

0 1 2 3 4 5 6 7 8 109 11 12 13 14 15

P2

P1

0 1 2 3 4 5 6 7 8 109 11 12 13 14 15

Page 12: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

12

Boundary Fair: A new approach

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 allocationMandatory units to keep fairnessOptional units for future urgent tasks

Dakai Zhu

Page 13: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

13

The Example: Bfair Schedule T1=(1, 3),

T2=(2, 5), T3=(2, 5), T4=(2, 3), T5=(1, 5)

0 1 2 3 4 5 6 7 8 109 11 12 13 14 15

T1 T2 T3 T4 T5

At boundary time 0: allocate [0 3)

Demand 1 6/5 6/5 2 3/5

Mandatory 1 1 1 2 0

pending 0 1/5 1 /5 0 3/5

Tasks T2, T3,T5 are eligible for the optional unit ?

P2

P1

Page 14: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

14

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: mi

k = max{ 0, RWik + wi*(bk+1 – bk) }

Optional units if: m*(bk+1 – bk) > mik

Page 15: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

15

Algorithm for Bfair Scheduler (cont.)

Eligible tasksPending work:PWi

k=RWik + wi*(bk+1 – bk) - mi

k > 0Not fully allocated: mi

k < 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) = ‘–’

TF ik=

1−(bk+sw i− ⌊bk+sw i ⌋)w i

Page 16: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

16

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

Page 17: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

17

The Example: Bfair Schedule (cont.) T1=(1, 3), T2=(2, 5),

T3=(2, 5), T4=(2, 3), T5=(1, 5)

0 1 2 3 4 5 6 7 8 109 11 12 13 14 15

T1 T2 T3 T4 T5

pending 0 1/5 1 /5 0 3/5

string * - - * -

* 0 0 * 0 UF

Mandatory 1 1 1 2 0

0 1 0 0 0 Optional

1 2 2

3 4 4

31 2 31 2 4 1 2 1 2

44 5 4 4 43 5 43 4

3

5

Compared BF vs. PF: Scheduling Points: 7 vs. 15Preemptions: 24 vs. 27

P2

P1

Page 18: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

Simulations and Discussions

Scheduling Points Execution time at each scheduling point Context switches Task Migrations

Page 19: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

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

Page 20: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 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

Page 21: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 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

Page 22: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 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

Page 23: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 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

Page 24: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 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

Page 25: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

1. C. L. Liu and James W. Layland. Scheduling algorithms for multiprogramming in a hard real-time environment. J. ACM, 20(1):46–61, 1973.

2. 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.

3. J.H. Anderson and A. Srinivasan. Early-release fair scheduling. In Proc. of the 12th Euromicro Conference on Real-Time Systems, Jun. 2000.

4. 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.

5. 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

Reference

Page 26: BFair: An Optimal Scheduler for Periodic Real-Time Tasks Hang Su The University of Texas at San Antonio hsu/ September 14, 2011

26

Questions and Comments