Fixed-Priority Multiprocessor Scheduling - Uppsala … Single-processors Liu and...

100
Fixed-Priority Multiprocessor Scheduling

Transcript of Fixed-Priority Multiprocessor Scheduling - Uppsala … Single-processors Liu and...

Fixed-Priority Multiprocessor Scheduling

Real-time Systems

N periodic tasks (of different rates/periods)

How to schedule the jobs to avoid deadline miss?

ri1 ri

2 ri3 ri

4

Ti Ti

Ji1 Ji

2 Ji3

Ti

Ci Ci

Ci

Utilization/workload:

On Single-processors

Liu and Layland’s Utilization Bound [1973]

(the 19th most cited paper in computer science)

Scheduled by RMS (Rate Monotonic Scheduling)

number of tasks

Rate Monotonic Scheduling

Priority assignment: shorter period higher prio.

Run-time schedule: the highest priority first

How to check whether all deadlines are met?

high priority

mediate priority

low priority

… …

… …

… …

Run-time schedule

Liu and Layland’s Utilization Bound

Schedulability Analysis

P

100%

Schedulable?

77.9%Ui 1 2 3

Ui = Ci / Ti

Liu and Layland’s bound:

Liu and Layland’s Utilization Bound

Schedulability Analysis

CPU

100%

Yes, schedulable!77.9%

Liu and Layland’s bound:

1

2

3

Multiprocessor (multicore) Scheduling

Significantly more difficult:

Timing anomalies

Hard to identify the worst-case scenario

Bin-packing/NP-hard problems

Multiple resources e.g. caches, bandwidth

… …

Quetion (since 1973)

Find a multiprocessor scheduling algorithm that can achieve Liu and Layland’s utilization bound

number of processors

?

Multiprocessor Scheduling

52

1 6

8

4

new task

waiting queue

cpu 1 cpu 2 cpu 3

Global Scheduling

cpu 1 cpu 2 cpu 3

5

1

2

8

6

3

9

7

4

cpu 1 cpu 2 cpu 3

2

5

2

1

22

3

6

7

4

2 3

Partitioned SchedulingPartitioned Scheduling

with Task Splitting

Best Known Results

20

10

30

40

60

50

70

80

Multiprocessor Scheduling

Global Partitioned

Fixed

Priority

Dynamic

Priority

Task Splitting

Fixed

Priority

Dynamic

Priority

Fixed

Priority

Dynamic

Priority

38

%

50

Liu and Layland’s

Utilization Bound

50 50

65 66

[OPODIS’08]

[TPDS’05] [ECRTS’03] [RTSS’04]

[RTCSA’06]

From UppsalaRTAS 2010

69.3

Multiprocessor Scheduling

52

1 6

8

4

new task

waiting queue

cpu 1 cpu 2 cpu 3

Global SchedulingWould fixed-priority schedulinge.g. “RMS” work?

Multiprocessor Scheduling

52

1 6

8

4

new task

waiting queue

cpu 1 cpu 2 cpu 3

Global SchedulingWould fixed-priority schedulinge.g. “RMS” work?

Unfortunately “RMS” suffersfrom the Dhall’s anomali

Utilization may be “0%”

Dhall’s anomali

1CPU1

CPU22

3

1

2

ε0 1+ ε1

CPU3

Dhall’s anomali

1CPU1

CPU22

1

2

ε0 1+ ε1

3 3

Schedule the 3 tasks on 2 CPUs using “RMS

Deadline miss

Dhall’s anomali

… …

P1 P2 PM

#1 #2 #M… …#M+1

M*ε + 1/(1+ ε)

ε/1 ε/1 ε/1

1/(ε+1)

0MU

(M+1 tasks and M processors)

Multiprocessor Scheduling

cpu 1 cpu 2 cpu 3

5

1

2

8

6

3

9

7

4

Partitioned Scheduling

Multiprocessor Scheduling

cpu 1 cpu 2 cpu 3

5

1

2

8

6

3

9

7

4

Partitioned Scheduling

Resource utilization maybe limited to 50%

Partitioned Scheduling

Partitioning

P1

1

P2 P3

1 31 2

4 5 6

7 8 9

Partitioned Scheduling

Partitioning

P1 P2 P3

3

1

2

4

5

6

7

8

9

Partitioned Scheduling

Scheduling

reduced to single-processor scheduling on each processor

P1 P2 P3

3

1

2

4

5

6

7

8

9

… …

… …

… …

P

100%

Yes, schedulable!77.9%

1

2

3

Partitioned Scheduling

The Partitioning Problem is similar to Bin-packing Problem (NP-hard)

Limited Resource Usage, 50% necessary condition to guarantee schedulability

… …

P1 P2 PM

#1 #2 #M… … #M+1 50%+ ε

Partitioned Scheduling

The Partitioning Problem is similar to Bin-packing Problem (NP-hard)

Limited Resource Usage necessary condition to guarantee schedulability

… …

P1 P2 PM

#1 #2 #M

… … #M+1 50%+ ε

Partitioned Scheduling

The Partitioning Problem is similar to Bin-packing Problem (NP-hard)

Limited Resource Usage necessary condition to guarantee schedulability

… …

P1 P2 PM

#1 #2 #M

… … #M+1,1 50%+ ε

#M+1,2

Partitioned Scheduling

The Partitioning Problem is similar to Bin-packing Problem (NP-hard)

Limited Resource Usage necessary condition to guarantee schedulability

… …

P1 P2 PM

#1 #2 #M

… …

#M+1,1

50%+ ε

#M+1,2

Multiprocessor Scheduling

cpu 1 cpu 2 cpu 3

2

5

2

1

22

3

6

7

4

2 3

Partitioned Schedulingwith Task Splitting

Partitioned Scheduling

Partitioning

P1

1

P2 P3

1 31 2

4 5 6

7 8 9

Bin-Packing with Item Splitting

Resource can be “fully” (better) utilized

Bin1 Bin2 Bin3

123

11

2 45

782

681

Depth-First Partitioning Algorithms [Kato et al. IPDPS’08] [Kato et al. RTAS’09] [Lakshmanan et al. ECRTS’09]

Sort the tasks e.g. in increasing priority order

Select a processor, and assign as many tasks as possible

3

4

2

5

1

6

8

7

highest priority

lowest priorityP1

Lakshmanan’s Algorithm [ECRTS’09]

Sort all tasks in decreasing order of utilization

3

4

2

5

1

6

8

7

lowest util.

highest util.

Lakshmanan’s Algorithm [ECRTS’09]

Pick up one processor, and assign as many tasks as possible

P1

3

4

2

5

1

6

8

7

lowest util.

highest util.

Lakshmanan’s Algorithm [ECRTS’09]

Pick up one processor, and assign as many tasks as possible

P1

8

3

4

2

5

1

6

7

lowest util.

highest util.

Lakshmanan’s Algorithm [ECRTS’09]

Pick up one processor, and assign as many tasks as possible

P1

8

3

4

2

5

1

6

7

lowest util.

highest util.

Lakshmanan’s Algorithm [ECRTS’09]

Pick up one processor, and assign as many tasks as possible

P1

8

3

4

2

5

1

62

7

61

lowest util.

highest util.

Lakshmanan’s Algorithm [ECRTS’09]

Pick up one processor, and assign as many tasks as possible

P1

8

3

4

2

5

1

62

7

61

P2

lowest util.

highest util.

Lakshmanan’s Algorithm [ECRTS’09]

Pick up one processor, and assign as many tasks as possible

P1

8

3

4

2

5

1

7

61

P2

62

lowest util.

highest util.

Lakshmanan’s Algorithm [ECRTS’09]

Pick up one processor, and assign as many tasks as possible

P1

8

3

4

2

1

7

61

P2

562

lowest util.

highest util.

Lakshmanan’s Algorithm [ECRTS’09]

Pick up one processor, and assign as many tasks as possible

P1

8

3

2

1

7

61

P2

562

4

lowest util.

highest util.

Lakshmanan’s Algorithm [ECRTS’09]

Pick up one processor, and assign as many tasks as possible

P1

8

2

1

7

61

P2

562

4

3

lowest util.

highest util.

Lakshmanan’s Algorithm [ECRTS’09]

Pick up one processor, and assign as many tasks as possible

P1

8

1

7

61

P2

562

4

321

22

lowest util.

highest util.

Lakshmanan’s Algorithm [ECRTS’09]

Pick up one processor, and assign as many tasks as possible

P1

8

7

61

P2

562

4

321

P3

22

1lowest util.

highest util.

Lakshmanan’s Algorithm [ECRTS’09]

Pick up one processor, and assign as many tasks as possible

P1

8

7

61

P2

562

4

321

P3

122

lowest util.

highest util.

Lakshmanan’s Algorithm [ECRTS’09]

Pick up one processor, and assign as many tasks as possible

P1

8

7

61

P2

562

4

321

P3

122

key feature:“depth-first” partitioning

with decreasing utilization orderlowest util.

highest util.

Lakshmanan’s Algorithm [ECRTS’09]

Pick up one processor, and assign as many tasks as possible

P1

8

7

61

P2

562

4

321

P3

122

Utilization Bound:

65%lowest util.

highest util.

Breadth-First Partitioning Algorithms [RTAS 2010]

Sort all tasks in increasing priority order

7

6

5

4

3

2

1highest priority

lowest priority

Select the processor on which the assigned utilization is the lowest

7

6

5

4

3

2

1

P1 P2 P3

highest priority

lowest priority

Breadth-First Partitioning Algorithms

Breadth-First Partitioning Algorithms

Select the processor on which the assigned utilization is the lowest

6

5

4

3

2

1

P1 P2 P3

7

highest priority

lowest priority

Breadth-First Partitioning Algorithms

Select the processor on which the assigned utilization is the lowest

5

4

3

2

1

P1 P2 P3

76

highest priority

lowest priority

Breadth-First Partitioning Algorithms

Select the processor on which the assigned utilization is the lowest

4

3

2

1

P1 P2 P3

76 5

highest priority

lowest priority

Breadth-First Partitioning Algorithms

Select the processor on which the assigned utilization is the lowest

3

2

1

P1 P2 P3

76 54

highest priority

lowest priority

Breadth-First Partitioning Algorithms

Select the processor on which the assigned utilization is the lowest

2

1

P1 P2 P3

76 54

3

highest priority

lowest priority

Breadth-First Partitioning Algorithms

Select the processor on which the assigned utilization is the lowest

1

P1 P2 P3

76 54

321

22

highest priority

lowest priority

Breadth-First Partitioning Algorithms

Select the processor on which the assigned utilization is the lowest

1

P1 P2 P3

76 54

32122

highest priority

lowest priority

Breadth-First Partitioning Algorithms

Select the processor on which the assigned utilization is the lowest

P1 P2 P3

76 54

321

12

11

22

highest priority

lowest priority

Breadth-First Partitioning Algorithms

Select the processor on which the assigned utilization is the lowest

P1 P2 P3

76 54

321 1211

22

Comparison

P1

8

7

61

P2

562

4

31

P3

1

2

32

P1 P2

3

P3

11

8

4

2

7 6

5

12

Why is the breadth algorithm better?

& increasing priority order

breadth-first depth-first

& decreasing utilization order

Split Task

Consider an extreme scenario:

suppose each subtask has the highest priority

schedulable anyway, we do not need to worry about their deadlines

The difficult case is when the tail task is not on the top

the key point is to ensure the tail task is schedulable

38

42

7 6

5

12 1113

Why the tail task is schedulable?

21 22

X1 X2

Y2

Y2 + U22 <= U2

1

That is, the “blocking factor” for the tail task is bounded.

U21

U22

The typical case: two CPUs and task 2 is split to two sub-tasks

As we always select the CPU with the lowest load assigned, we know

Y2 <= U21 - U2

2

Theorem

For a task set in which each task satisfies

we have

Theorem

For a task set in which each task satisfies

we have

get rid of this constraint

Problem of Heavy Tasks

P1 P2 P3

highest priority

lowest priority

5

4

2

1

8

7

6

9

3

Problem of Heavy Tasks

P1 P2 P3

highest priority

lowest priority

5

4

2

1

8

7

6

9

3

Problem of Heavy Tasks

P1 P2 P3

highest priority

lowest priority

5

4

2

1

8

7

6

9

3

Problem of Heavy Tasks

P1 P2 P3

highest priority

lowest priority

5

4

2

1

8 7

6

9

3

Problem of Heavy Tasks

P1 P2 P3

highest priority

lowest priority

5

4

2

1

8 762

9

3

61

Problem of Heavy Tasks

P1 P2 P3

highest priority

lowest priority

5

4

2

1

8 762

9

3

61

Problem of Heavy Tasks

P1 P2 P3

highest priority

lowest priority

5

4

2

1

8 762

9

3

61

Problem of Heavy Tasks

P1 P2 P3

highest priority

lowest priority

54

2

1

8 762

9

3

61

Problem of Heavy Tasks

P1 P2 P3

highest priority

lowest priority

54

2

1

8 762

9

361

Problem of Heavy Tasks

P1 P2 P3

highest priority

lowest priority

54

2

1

8 762

9

361

Problem of Heavy Tasks

P1 P2 P3

54

21

8 762

9

361

Problem of Heavy Tasks

P1 P2 P3

54

21

8 762

9

361

the heavy tasks’ tail task may have too low priority level

Solution for Heavy Tasks

Pre-assigning the heavy tasks (that may have low priorities)

P1 P2 P3

highest priority

lowest priority

5

4

2

1

8

7

6

9

3

Solution for Heavy Tasks

Pre-assigning the heavy tasks (that may have low priorities)

P1 P2 P3

highest priority

lowest priority

5

4

2

1

8

7

6

9

3

Solution for Heavy Tasks

Pre-assigning the heavy tasks (that may have low priorities)

P1 P2 P3

highest priority

lowest priority

5

4

2

1

8

7

6

9

3

Solution for Heavy Tasks

Pre-assigning the heavy tasks (that may have low priorities)

P1 P2 P3

highest priority

lowest priority

5

4

2

1

8

7

6

9

3

Solution for Heavy Tasks

Pre-assigning the heavy tasks (that may have low priorities)

P1 P2 P3

highest priority

lowest priority

5

4

2

1

876

9

3

Solution for Heavy Tasks

Pre-assigning the heavy tasks (that may have low priorities)

P1 P2 P3

highest priority

lowest priority

5

4

2

1

876

9

3

Solution for Heavy Tasks

Pre-assigning the heavy tasks (that may have low priorities)

P1 P2 P3

highest priority

lowest priority

54

2

1

876

9

3

Solution for Heavy Tasks

Pre-assigning the heavy tasks (that may have low priorities)

P1 P2 P3

highest priority

lowest priority

54

2

1

876

9

3

Solution for Heavy Tasks

Pre-assigning the heavy tasks (that may have low priorities)

P1 P2 P3

highest priority

lowest priority

542

1

876

9

3

Solution for Heavy Tasks

Pre-assigning the heavy tasks (that may have low priorities)

P1 P2 P3

highest priority

lowest priority

542

12

876

9

311

Solution for Heavy Tasks

Pre-assigning the heavy tasks (that may have low priorities)

P1 P2 P3

542

876

9

31112

Solution for Heavy Tasks

Pre-assigning the heavy tasks (that may have low priorities)

P1 P2 P3

542

876

9

31112

avoid to split heavy tasks (that may have low priorities)

Theorem

By introducing the pre-assignment mechanism, we have

Liu and Layland’s utilization bound for all task sets!

Overhead

In both previous algorithms and ours

The number of task splitting is at most M-1

task splitting -> extra “migration/preemption”

Our algorithm on average has less task splitting

P1 P2 P3P1 P2 P3

Ours: width-first depth-first

Implementation

Easy!

One timer for each split task

Implemented as “task migration”

i1

Ci1

P1

P2

task i

higher prio

tasks

i2

until finished

as being resumed

as being preempted

lower prio

tasks

Further Improvement

P1

100%

Schedulable?P2 P3

3

2

1

6

5

4

9

8

7

Uisng Liu and Layland’s Utilization Bound

P1 P2 P3

Yes, schedulable by our algorithm 100%

Utilization Bound is Pessimistic

The Liu and Layland utilization bound is sufficient but not necessary

many task sets are actually schedulable even if the total utilization is larger than the bound

P

10.69

(1, 4)

(2, 12)

(1, 4)

(2, 8)

Exact Analysis

Exact Analysis: Response Time Analysis [Lehoczky_89]

pseudo-polynomial

(1, 4)

(2, 12)

(1, 4)

(2, 8)

Rk

task k is schedulable iff Rk <= Tk

Utilization Bound v.s. Exact Analysis

On single processors

P

100%

Utilization bound Testfor RMS

P

Exact Analysisfor RMS

[Lehoczky_89]

88%100%

On Multiprocessors

Can we do something similar on multiprocessors?

P1 P2 P3

Utilization bound Testthe algorithm introduced above ?

P1 P2 P3

100% 100%

An Improved Algorithm

Based on the similar idea

RMS priority assignment

worst-fit partitioning

increasing priority order

Employ Response Time Analysis to determine the maximal workload on each processor

more flexible behavior (more difficult to prove …)

Same utilization bound

Liu and Layland’s utilization bound

Much better performance

Pseudo-polynomial

Summary

Real-time Systems

infinite, multi-task, multi-rate … …

Summary

Real-time Systems

infinite, multi-task, multi-rate … …

On Single-processors

Liu and Layland’s Utilization bound

80

70

60

50

40

30

20

10

0

%Liu and Layland’s Utilization Bound

Summary

Real-time Systems

infinite, multi-task, multi-rate … …

On Single-processors

Liu and Layland’s Utilization bound

On Multiprocessors

80

70

60

50

40

30

20

10

0

%Liu and Layland’s Utilization Bound

Multiprocessor Scheduling

Summary

Real-time Systems

infinite, multi-task, multi-rate … …

On Single-processors

Liu and Layland’s Utilization bound

On Multiprocessors

Global Scheduling

Dhall’s Effect80

70

60

50

40

30

20

10

0

%Liu and Layland’s Utilization Bound

38

[OPODIS’08]

Global

Multiprocessor Scheduling

1P1

P22

P3 3

4

1

2

34 4

deadline miss

ε0 1+ ε1

Summary

Real-time Systems

infinite, multi-task, multi-rate … …

On Single-processors

Liu and Layland’s Utilization bound

On Multiprocessors

Global Scheduling

Dhall’s Effect

Partitioned Scheduling

Bin-packing

80

70

60

50

40

30

20

10

0

%Liu and Layland’s Utilization Bound

38

[OPODIS’08]

Global

Multiprocessor Scheduling

50

[ECRTS’03]

Partitioned

Summary

Real-time Systems

infinite, multi-task, multi-rate … …

On Single-processors

Liu and Layland’s Utilization bound

On Multiprocessors

Global Scheduling

Dhall’s Effect

Partitioned Scheduling

Bin-packing

Our Recent Work

Partitioned with Task Splitting

split tasks with high priorities

Liu and Layland’s utilization bound

80

70

60

50

40

30

20

10

0

%Liu and Layland’s Utilization Bound

38

[OPODIS’08]

Global

Multiprocessor Scheduling

50

[ECRTS’03]

Partitioned

[Our Work]

Splitting

References

[Liu1973] C.L. Liu and James Layland, Scheduling Algorithms for Multiprogramming in a Hard-Real-Time Environment

[Andersson03ECRTS] Bjorn Andersson, Jan Jonsson: The Utilization Bounds of partitioned and Pfair Static-Priority Scheduling on multiprocessors are 50%. ECRTS 2003

[Andersson08OPODIS] Bjorn Andersson: Global Static-Priority Preemptive Multiprocessor Scheduling with Utilization Bound 38%. OPODIS 2008

[Andersson06RTCSA] Bjorn Andersson, Eduardo Tovar: Multiprocessor Scheduling with Few preemption. RTCSA 2006

[Andersson01RTSS] Bjorn Andersson, Sanjoy K. Baruah, Jan Jonsson: Static-Priority Scheduling on multiprocessors. RTSS 2001

[Baker05TPDS] Theodore P. Baker: An Analysis of EDF Schedulability on a Multiprocessor. IEEE Trans. Parallel Distrib. Syst. 16(8): 760-768 (2005)

[Lakshmanan09ECRTS] Karthik Lakshmanan, Ragunathan Rajkumar, John Lehoczky Partitioned Fixed-Priority Preemptive Scheduling for Multi-core Processors. ECRTS 20006

[Lopez04RTSS] J. M. Lopez, J. L. Diaz, and D. F. Garcia, ”Utilization Bounds for EDF Scheduling on Real-Time Multiprocessor Systems”, RTSS 2004.

[Oh98] D. Oh and T. P. Baker. Utilization bounds for n-processor Rate Monotone scheduling with static processor assignment. In Real-Time Systems, 1998.

[Kato08IPDPS] Shinpei Kato, Nobuyuki Yamasaki: Portioned static-priority scheduling on multiprocessors. IPDPS 2008

[Kato09RTAS] Shinpei Kato, Nobuyuki Yamasaki: Semi-partitioned Fixed-Priority Scheduling on Multiprocessors. RTAS 2009.