eecs 571 “principles of real-time embedded systems” lecture note #8: task assignment and...

22
EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems Kang G. Shin EECS Department University of Michigan

Upload: lamhuong

Post on 18-Sep-2018

227 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

EECS 571 “Principles of Real-Time EmbeddedSystems”

Lecture Note #8: Task Assignment and Schedulingon Multiprocessor Systems

Kang G. ShinEECS Department

University of Michigan

Page 2: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

What Have We Done So Far?

• Scheduling a set of tasks with various constraintson a single processor.

• What should we do if schedulability condition forthe given task set can’t be met?

• Question: which tasks should be assigned towhich processors and why?

• Ideally, combined task assignment andscheduling is desirable, but this is very hard .

• Common approach: assign tasks and thenschedule them on each processor.

Kang Shin ([email protected])

Page 3: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Task Assignment

• What should we consider for task assignment ?

• NP-Complete ⇒ Use heuristicsExamples:

• Utilization-balancing algorithm: assign tasksone-by-one selecting the least utilized processor

∑pi=1(u

Bi )2

∑pi=1(u

∗i )

2≤

9

8

where u∗i = Pi’s utilization under an optimal alg. that

minimizes∑

utilization2

uBi = Pi’s utilization under best-fit alg.

Kang Shin ([email protected])

Page 4: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Next-fit alg for RM scheduling

• Homogeneous multiprocessor systems

• There are m classes of tasks such that

o Ti belongs to class j < m if

21

j+1 − 1 <eipi

≤ 21j − 1.

o Ti belongs to class m otherwise.

• Each class of tasks are assigned to acorresponding set of processors.

Kang Shin ([email protected])

Page 5: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

ExampleThere are m = 4 task classes

Class Untilization boundC1 (0.41, 1.00]C2 (0.26, 0.41]C3 (0.19, 0.26]C4 (0.00, 0.19]

Task set

T1 T2 T3 T4 T5 T6 T7

ei 5 7 3 1 10 16 1Pi 10 21 22 24 30 40 50

u(i) 0.50 0.33 0.14 0.04 0.33 0.40 0.02Class C1 C2 C4 C4 C2 C2 C4

Processor 1 2 4 4 2 5 4T8 T9 T10 T11

ei 3 9 17 21Pi 55 70 90 95

u(i) 0.05 0.13 0.19 0.22Class C4 C4 C4 C3

Processor 4 4 4 3

Kang Shin ([email protected])

Page 6: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Bin-packing assignment for EDF

• Same assumptions on tasks and processors asNext-fit alg.

• Task set is EDF-schedulable if U ≤ 1.

• Assign tasks such that U ≤ 1 for all processors.

Kang Shin ([email protected])

Page 7: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Myopic offline scheduling alg

• Can consider resources other than CPU

• Given: set of tasks, their arrival times, executiontimes, deadlines.

• Allocation tree:

o Root: null allocation

o Node: an assignment and scheduling of a subset oftasks.

o child node: parent’s allocation + a task

o leaf: “complete” allocation.

o How many levels for an n-task system?

o A level-i node means?

o Very expensive to generate a complete allocation tree⇒ heuristics.

Kang Shin ([email protected])

Page 8: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Combined Assignment and Scheduling

• Static (offline) assignment of periodic and/orcritical tasks: myopic scheduling, B&B alg.

• Dynamic (online) load sharing of aperiodicsand/or non-criticals

o Bidding

o Focused addressing

o Drafting

o Buddy

Kang Shin ([email protected])

Page 9: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Offline Allocation of PeriodicsIEEE Trans. on Software Engineering, vol. 23, no. 12,

pp. 745–758, Dec. 1997

• Task allocation: combined task assignment andscheduling of periodics

o Derive an “optimal” assignment that yields feasibleschedules for all processors. How ?

• Main features:

o Inter-task communications ⇒ precedence constraintshence task structure.

o Tasks are periodic and time-critical ⇒ allocationobjective function.

• Want allocation x of communicating periodictasks in a heterogeneous distributed system thatminimizes system hazard , Θ(x), or maximumnormalized task response time.

Kang Shin ([email protected])

Page 10: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

System Model

• Tasks T = {Ti : i = 1,2, . . . , m};Heterogeneous PNsN = {Nk : k = 1,2, . . . , n}.

• Allocation constraints:

o Co-location of Ti and Tj on same PN.

o Location of Ti and Tj on different PNs.

o Location of Ti on a special PN.

• Task invocations and release times, precedenceconstraints, planning cycle.

• Execution times of computation andcommunication modules.

Kang Shin ([email protected])

Page 11: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Example Task Graph

d

d

14,24

21,15

8,20d

17,9dM1 M2

M3

M4 M5

M12

M11

M10

M13 M14

M15

M16

M17

M18

M19

M20

M21

M23

M22

M24

L=40

M6 M7 M8

M9d

d

2,10

12,5

1 2 3T (P = 40) T (P = 40) T (P = 20)1 2 3

Kang Shin ([email protected])

Page 12: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Problem Formulation

• Normalized task response time of the v-thinvocation of Ti:

civ =civ − riv

div − riv

• System hazard under allocation x:

Θx = maxTi∈T civ

• Problem: find an optimal x∗ that minimizes thesystem hazard.

• Both civ and Θx depend on:

o how tasks are assigned under x and

o how assigned tasks are scheduled on eachPN.

Kang Shin ([email protected])

Page 13: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Task Allocation Algorithm

• Consists of two branch-and-bound algorithms,one for assignment (B&BA) and the other forscheduling (B&BS).

• Same as traversing a tree

• Vertex = allocation

• Complete allocation = leaf node; B&BS alg

• Partial allocation = intermediate vertex; B&BS istoo expensive, so compute and use a lowerbound of optimal system hazard

Kang Shin ([email protected])

Page 14: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Branch and Bound Algorithm

1 let active set A = {Root}2 let vertex cost Θ(Root) = 03 let best solution cost, Θmin = ∞

4 while true do5 let Vbest = minimum cost vertex in A

6 if Vbest is a leaf vertex then7 prune all vertices V ∈ A except Vbest

8 return Vbest as optimal solution9 else10 generate (task assignments of) all children of Vbest

11 remove Vbest from active set A

12 for each child x of Vbest do13 if assignment constraints in set AC are not satisfied then prune x

14 else15 compute vertex cost Θ(x)16 add x to active set A

17 if x is a leaf vertex then18 if Θ(x) < Θmin then19 Θmin = Θ(x)20 prune all vertices V ∈ A for which V 6= x and Θ(V ) ≥ Θmin

21 else prune x

22 end if23 end if24 end for25 end if26end while

Kang Shin ([email protected])

Page 15: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Search Tree

(T1, N1)

(T1, N1) (T1, N1) (T1, N1) (T1, N1)

(T1, N2)

(T1, N2)(T1, N2)(T2, N1) (T2, N2)

(T2, N1) (T2, N1) (T2, N2) (T2, N2) (T2, N1) (T2, N1) (T2, N2) (T2, N2)(T3, N1) (T3, N2) (T3, N1) (T3, N2) (T3, N1) (T3, N2) (T3, N1) (T3, N2)

(T1, N1)(T2, N1)

(T1, N1)(T2, N2)

Allocating T1

Allocating T2

Allocating T3

Root of the Search Tree

(T1, N2) (T1, N2) (T1, N2) (T1, N2)

1

2 3

4 5 6 7

8 9 151413121110

Kang Shin ([email protected])

Page 16: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

B&BA Algorithm

• A terminal vertex or complete assignment: B&BSalg based on dominance properties.

• For each non-terminal vertex or partialassignment x:

o B&BS is too expensiveo As long as a lower-bound, Θx

lb of the optimalcost for x is used, B&BA will find an optimalassignment.

o Θxlb is obtained by relaxing task invocation

times, precedence constraints, etc.

Kang Shin ([email protected])

Page 17: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Computing Lower-Bound Vertex Cost

1. Compute the minimum computational loadimposed on each processor by tasks alreadyassigned to PNs at search vertex x.

2. Estimate the minimum additional load to beimposed on each PN due to those tasks not yetassigned at x.

3. Schedule the combined load at each PN andcompute the system hazard. We ensure that thesystem hazard of the resulting schedule is alower bound on the system hazard of any leafvertex descending from x, i.e., it representsΘ(x) = Θlb(x).

Kang Shin ([email protected])

Page 18: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

B&BS Algorithms

Scheduling tasks w.r.t. Θ for a given completeassignment is NP-Hard ⇒ Dominance properties arederived to guide search for an optimal schedule.

• Preemptions which do not reduce Θ must bedisallowed.

• A PN is not allowed to idle when there are ready(uncompleted) modules on the PN.

• Always advantageous to reduce the completiontime of a task without increasing others’.

Kang Shin ([email protected])

Page 19: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Example

The same as before: 3 tasks and 2 PNsModule execution times on N1

Mj ej1 Mj ej1 Mj ej1

M1 4 M9 1:3 M17 1:3M2 1:4 M10 1:4 M18 1M3 2 M11 1 M19 2M4 2 M12 2:4 M20 0:1M5 2:6 M13 2 M21 1:3M6 2 M14 0:2 M22 1M7 1 M15 2:3 M23 2M8 1:2 M16 3 M24 1:2

Kang Shin ([email protected])

Page 20: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Search Tree Generated and Optimal Schedule

(T1, N1) (T1, N2)

(T1, N2)(T1, N2)(T2, N1) (T2, N2)

(T2, N2) (T2, N2)(T3, N1) (T3, N2)

(T1, N1)(T2, N1)

(T1, N1)(T2, N2)

1

2

4 5

3

6 7

8 9

40

39

40

27.5

40

14

40

20

40

23.528

40

0

40

7

23.5

40

(T1, N2) (T1, N2)

5 19 23.5 27.5

11 2131 32T T T T

0 5 10 15 20 25 30 35 40

N

N

2

1

Time

Processor

Kang Shin ([email protected])

Page 21: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Task Graph at Vertex 5

14,24d

21,15d

8,20d

17,9d

= 82,10d

= min {5,1} = 12

ρ

= 01

ρ

= min {4,0.5} = 0.52

ρ

= 01

ρ

L=40

d12,5

e =0.5

e =1.5

3

4 5

6 7 8

9

12 13 14

15

T (P = 40) T (P = 40) T (P = 20)1 2 31 2 3

1 2e = 1 e =0.5 e =0.5

e =0.5

11

e =2 e =1 e =0

e =1

16

= 10

10e = 2

e = 4 e = 4

e = 2

e = 2 e = 6

Kang Shin ([email protected])

Page 22: EECS 571 “Principles of Real-Time Embedded Systems” Lecture Note #8: Task Assignment and Scheduling … · Lecture Note #8: Task Assignment and Scheduling on Multiprocessor Systems

Computational Experiences

Tasks Expanded Vertices Total Space % Expanded6 18 4096 0.438 65 65536 0.1

10 95 1048576 0.0112 133 16777216 0.000814 274 268435456 0.0000004

Nodes Expanded Vertices Coef of Variation Total Space % Expanded2 16 0.35 256 6.174 37 0.8 65536 0.066 38 0.8 1679616 0.002

Kang Shin ([email protected])