embedded systems – exercise 4: scheduling periodic and ... · |11./13.11.2020 | 33 mixed task...

65
| | Roman Trüb, [email protected] Computer Engineering Group, ETH Zurich 1 Embedded Systems – Exercise 4: Scheduling Periodic and Mixed Task Sets 11./13.11.2020 Roman Trüb

Upload: others

Post on 03-Feb-2021

6 views

Category:

Documents


0 download

TRANSCRIPT

  • ||

    Roman Trüb, [email protected]

    Computer Engineering Group, ETH Zurich

    1

    Embedded Systems – Exercise 4:

    Scheduling Periodic and Mixed Task Sets

    11./13.11.2020Roman Trüb

  • || 11./13.11.2020 2

    Exercise Structure

    Goal of today’s exercise:

    ▪ Learn and apply scheduling schemes for periodic and mixed task sets.

    Agenda:

    ▪ Wednesday 16:15 – 17:00 Clicker quiz (recorded)

    Lecture summary (recorded)

    Solving a sample task (recorded)

    Tasks of exercise 4 (recorded)

    Q & A

    ▪ Friday 16:15 – 17:00 Solution discussion (recorded)

    Q & A

    Available Assistants:

    ▪ Roman Trüb - TA

    ▪ Joël Küchler - SA

    Roman Trüb

  • || 11./13.11.2020 3

    Clicker Quiz

    Roman Trüb

  • || 11./13.11.2020 4

    Clicker Quiz – Question 1

    Schedulable with EDF

    Test failed

    Task set is not schedulable with EDF

    Roman Trüb

  • || 11./13.11.2020 5

    Clicker Quiz – Question 2

    Roman Trüb

    Schedulable with RM

    With this test result, no statement can be made since

    schdulablility test condition is not necessary.

    Task set could still be schedulable with RM.

  • || 11./13.11.2020 6

    Clicker Quiz – Question 3

    Roman Trüb

  • || 11./13.11.2020 7

    Clicker Quiz – Question 4

    Roman Trüb

  • || 11./13.11.2020 8

    Lecture Summary

    Roman Trüb

  • || 11./13.11.2020 9

    Scheduling Algorithms

    Roman Trüb

    Periodic with

    D = T

    Periodic with

    D < TMixed Tasks

    Static

    PriorityRM DM Polling Server

    Dynamic

    PriorityEDF EDF

    Total

    Bandwidth

    Server

  • || 11./13.11.2020 10

    Scheduling Periodic Task Sets [6-33f]

    Roman Trüb

    Periodic with

    D = T

    Periodic with

    D < TMixed Tasks

    Static

    PriorityRM DM Polling Server

    Dynamic

    PriorityEDF EDF

    Total

    Bandwidth

    Server

  • || 11./13.11.2020 11

    Rate Monotonic (RM)

    Roman Trüb

    Static priority assignment:

    Tasks with shorter period get higher priority

    t

    tT1

    tT3

    tT2

  • || 11./13.11.2020 12

    Rate Monotonic (RM)

    Roman Trüb

    Static priority assignment:

    Tasks with shorter period get higher priority

    t

    tT1

    tT3

    High

    Low

    tT2

  • || 11./13.11.2020 13

    Rate Monotonic (RM)

    Roman Trüb

    Static priority assignment:

    Tasks with shorter period get higher priority

    t

    tT1

    tT3

    High

    Low

    tT2

  • || 11./13.11.2020 14

    Rate Monotonic (RM)

    Roman Trüb

    Static priority assignment:

    Tasks with shorter period get higher priority

    t

    tT1

    tT3

    High

    Low

    tT2

  • || 11./13.11.2020 15

    Rate Monotonic (RM)

    Roman Trüb

    Static priority assignment:

    Tasks with shorter period get higher priority

    t

    tT1

    tT3

    High

    Low

    tT2

  • || 11./13.11.2020 16

    Rate Monotonic (RM)

    Roman Trüb

    Static priority assignment:

    Tasks with shorter period get higher priority

    t

    tT1

    tT3

    High

    Low

    tT2

  • || 11./13.11.2020 17

    RM – Schedulability Test

    Roman Trüb

    Sufficient

    (but not necessary)

  • || 11./13.11.2020 18

    Scheduling Periodic Task Sets [6-33f]

    Roman Trüb

    Periodic with

    D = T

    Periodic with

    D < TMixed Tasks

    Static

    PriorityRM DM Polling Server

    Dynamic

    PriorityEDF EDF

    Total

    Bandwidth

    Server

  • || 11./13.11.2020 19

    Deadline Monotonic (DM)

    Roman Trüb

    Static priority assignment:

    Tasks with smaller relative deadline get higher priority

    tT3

    t

    tT1

    tT2

  • || 11./13.11.2020 20

    Deadline Monotonic (DM)

    Roman Trüb

    Static priority assignment:

    Tasks with smaller relative deadline get higher priority

    t

    tT1

    tT2

    High

    Low

    tT3

  • || 11./13.11.2020 21

    Deadline Monotonic (DM)

    Roman Trüb

    Static priority assignment:

    Tasks with smaller relative deadline get higher priority

    t

    tT1

    tT2

    High

    Low

    tT3

  • || 11./13.11.2020 22

    Deadline Monotonic (DM)

    Roman Trüb

    Static priority assignment:

    Tasks with smaller relative deadline get higher priority

    t

    tT1

    tT2

    High

    Low

    tT3

  • || 11./13.11.2020 23

    Deadline Monotonic (DM)

    Roman Trüb

    Static priority assignment:

    Tasks with smaller relative deadline get higher priority

    t

    tT1

    tT2

    High

    Low

    tT3

  • || 11./13.11.2020 24

    Deadline Monotonic (DM)

    Roman Trüb

    Static priority assignment:

    Tasks with smaller relative deadline get higher priority

    t

    tT1

    tT2

    High

    Low

    tT3

  • || 11./13.11.2020 25

    DM – Schedulability Test

    Roman Trüb

    Sufficient

    (but not necessary)

  • || 11./13.11.2020 26

    RM & DM – Schedulability Test

    Roman Trüb

    Necessary &

    Sufficient

    Ri Ri+Ci

    Worst-case

    Interference:

    Longest Response Time Ri(computed iteratively)

    Assumption: Tasks are

    ordered according to their

    priorities:

  • || 11./13.11.2020 27

    Scheduling Periodic Task Sets [6-33f]

    Roman Trüb

    Periodic with

    D = T

    Periodic with

    D < TMixed Tasks

    Static

    PriorityRM DM Polling Server

    Dynamic

    PriorityEDF EDF

    Total

    Bandwidth

    Server

  • || 11./13.11.2020 28

    Earliest Deadline First (EDF)

    Roman Trüb

    Dynamic Priority Assignment:

    Always execute the task with the currently closest deadline

    t

    tT1

    tT3

    tT2

  • || 11./13.11.2020 29

    Earliest Deadline First (EDF)

    Roman Trüb

    Dynamic Priority Assignment:

    Always execute the task with the currently closest deadline

    t

    tT1

    tT3

    tT2

  • || 11./13.11.2020 30

    Earliest Deadline First (EDF)

    Roman Trüb

    Dynamic Priority Assignment:

    Always execute the task with the currently closest deadline

    t

    tT1

    tT3

    tT2

  • || 11./13.11.2020 31

    Earliest Deadline First (EDF)

    Roman Trüb

    Dynamic Priority Assignment:

    Always execute the task with the currently closest deadline

    t

    tT1

    tT3

    tT2

  • || 11./13.11.2020 32

    EDF – Schedulability Tests

    Roman Trüb

    Di= Ti Di< Ti

    Sufficient

    (but not necessary)

    Necessary &

    Sufficient

    Utilization:

  • || 11./13.11.2020 33

    Mixed Task Scheduling

    Roman Trüb

    • Mixed (or hybrid) task set contains both periodic and

    aperiodic tasks

    • Basic idea for scheduling:

    • Schedule the periodic tasks as usual

    • Serve the aperiodic tasks via a "server" that behaves

    like a periodic task but serves the aperiodic tasks

  • || 11./13.11.2020 34

    Scheduling Mixed Task Sets [6-64f]

    Roman Trüb

    Periodic with

    D = T

    Periodic with

    D < TMixed Tasks

    Static

    PriorityRM DM Polling Server

    Dynamic

    PriorityEDF EDF

    Total

    Bandwidth

    Server

  • || 11./13.11.2020 35

    Polling Server (RM)

    Roman Trüb

    Idea: Introduce an artificial periodic task (Cs, Ts) which serves the aperiodic

    requests

    Schedulability test for mixed task set:Sufficient

    (but not necessary)

    Sufficient

    (but not necessary)

    Aperiodic guarantee (schedulability test for aperodic requests):

    Assumption: aperiodic task finishes

    before new aperiodic request arrives

  • || 11./13.11.2020 36

    Scheduling Mixed Task Sets [6-64f]

    Roman Trüb

    Periodic with

    D = T

    Periodic with

    D < TMixed Tasks

    Static

    PriorityRM DM Polling Server

    Dynamic

    PriorityEDF EDF

    Total

    Bandwidth

    Server

  • || 11./13.11.2020 37

    Total Bandwidth Server (EDF)

    Roman Trüb

    Idea: For every aperiodic request a deadline which is based on the server’s

    parameters (Cs, Ts) is assigned. The aperiodic requests are then scheduled with

    EDF as any other periodic instance.

    Assignment of the deadlines to the aperiodic requests:

    NOTE: recursive

    computation!

    Aperiodic requests

    are assumed to be

    ordered by increasing

    release time ri

  • || 11./13.11.2020 38

    Total Bandwidth Server (EDF)

    Roman Trüb

    Schedulability test for mixed task set: Necessary & Sufficient

    Set of periodic tasks with

    utilization Up and a Total

    Bandwidth Server with utilization

    Us is schedulable with EDF

    Utilization of Total Bandwidth Server:

    Utilization of the periodic tasks:

  • || 11./13.11.2020 39

    Sample Task

    (Task 4a)

    Roman Trüb

  • || 11./13.11.2020 40Roman Trüb

  • || 11./13.11.2020 41

    First Try Sufficient (But Not Necessary) Scheduling Test.

    Roman Trüb

    Test failed. No statement can be made (since test is sufficient but not necessary).

  • || 11./13.11.2020 42

    RM & DM – Schedulability Test

    Roman Trüb

    Necessary &

    Sufficient

    Ri Ri+Ci

    Worst-case

    Interference:

    Longest Response Time Ri(computed iteratively)

    Assumption: Tasks are

    ordered according to their

    priorities:

  • || 11./13.11.2020 43

    Apply Sufficient and Necessary Scheduling Test [6-54]

    Roman Trüb

    1. Order tasks according to their priorities (relative deadlines for DM):

  • || 11./13.11.2020 44

    Apply Sufficient and Necessary Scheduling Test [6-54]

    Roman Trüb

    1. Order tasks according to their priorities (relative deadlines for DM):

    2. Apply iterative algorithm to find longest response time for each task, starting

    with last task

  • || 11./13.11.2020 45

    Apply Sufficient and Necessary Scheduling Test [6-54]

    Roman Trüb

    1. Order tasks according to their priorities (relative deadlines for DM):

    2. Apply iterative algorithm to find longest response time for each task, starting

    with last task

  • || 11./13.11.2020 46

    Apply Sufficient and Necessary Scheduling Test [6-54]

    Roman Trüb

    1. Order tasks according to their priorities (relative deadlines for DM):

    2. Apply iterative algorithm to find longest response time for each task, starting

    with last task

  • || 11./13.11.2020 47

    Apply Sufficient and Necessary Scheduling Test [6-54]

    Roman Trüb

    1. Order tasks according to their priorities (relative deadlines for DM):

    2. Apply iterative algorithm to find longest response time for each task, starting

    with last task

  • || 11./13.11.2020 48

    Apply Sufficient and Necessary Scheduling Test [6-54]

    Roman Trüb

    1. Order tasks according to their priorities (relative deadlines for DM):

    2. Apply iterative algorithm to find longest response time for each task, starting

    with last task

  • || 11./13.11.2020 49

    Apply Sufficient and Necessary Scheduling Test [6-54]

    Roman Trüb

    1. Order tasks according to their priorities (relative deadlines for DM):

    2. Apply iterative algorithm to find longest response time for each task, starting

    with last task

  • || 11./13.11.2020 50

    Apply Sufficient and Necessary Scheduling Test [6-54]

    Roman Trüb

    Test failed.

    Task set is not schedulable using the Deadline Monotonic scheduling scheme.

    1. Order tasks according to their priorities (relative deadlines for DM):

    2. Apply iterative algorithm to find longest response time for each task, starting

    with last task

  • || 11./13.11.2020 51

    Exercise 4

    Roman Trüb

  • || 11./13.11.2020 52Roman Trüb

  • || 11./13.11.2020 53Roman Trüb

  • || 11./13.11.2020 54Roman Trüb

  • || 11./13.11.2020 55

    Exercise 4 - Solution

    Roman Trüb

  • || 11./13.11.2020 56Roman Trüb

  • || 11./13.11.2020 57

    Task 1 – Solution

    Roman Trüb

    a) Maximum utilization of the server:

    b) Order tasks by increasing release time: J4, J6, J5

    Then, calculate new deadlines recursively:

  • || 11./13.11.2020 58

    Task 1 – Solution

    Roman Trüb

    b) EDF schedule with aperiodic tasks:

  • || 11./13.11.2020 59Roman Trüb

  • || 11./13.11.2020 60

    Task 2 – Solution

    Roman Trüb

    a) Sufficient test:

    Test failed! Since it is not necessary, we still don’t know if the task set is

    schedulable with RM or not.

  • || 11./13.11.2020 61

    Task 2 – Solution

    Roman Trüb

    b) Necessary test: Iterative algorithm

    1) Order tasks by their priority (already ok in this case)

    2) Start with task which has lowest priority:

    Necessary test succeeds task set is schedulable with RM

  • || 11./13.11.2020 62

    Task 2 – Solution

    Roman Trüb

    c) RM schedule

    (there are no deadline misses)

  • || 11./13.11.2020 63Roman Trüb

  • || 11./13.11.2020 64

    Task 3 – Solution

    Roman Trüb

    a) Aperiodic guarantee:

    b) Sufficient schedulability test for RM Polling Server:

    Test succeeded!

    Substituting values & considering minimum

    Task set is schedulable with RM

  • || 11./13.11.2020 68

    Exercise Session is Over

    ▪ The assistants are now available until roughly 17:00 to answer questions.

    ▪ Zoom: Ask in this Zoom channel

    ▪ Matrix-Chatroom: Ask a question in the chatroom so other students can also profit from the

    response (or respond even quicker!)

    ▪ Email: For individual questions, you can also reach me under [email protected] .

    Roman Trüb