22
September 22, 2020 Sam Siewert CEC 450 Real - Time Systems Lecture 4 Rate Monotonic Theory Part 3

CEC 450 Real-Time Systemsmercury.pr.erau.edu/.../Lectures/Lecture-Week-4-2.pdf · 2020. 9. 22. · September 22, 2020 Sam Siewert CEC 450 Real-Time Systems Lecture 4 – Rate Monotonic

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

  • September 22, 2020 Sam Siewert

    CEC 450Real-Time Systems

    Lecture 4 – Rate Monotonic TheoryPart 3

  • Sam Siewert 2

    Detailed Algebra Notes (p. 82)

    ( ) ( )[ ] ( ) [ ]1212121221 /////1 TTTTTTTTTTU −−−=

    Plug C1 and C2 into U equation

    Substitute in definition of C1

    Take simple equationsat intersection

    Re-arrange the terms

    Pull out -(T1/T2)

    We get U in terms of T1 and T2 only

    Factor into

  • Sam Siewert 3

    RM LUB Derivation

    ( ) ( )[ ] ( ) [ ]1212121221 /////1 TTTTTTTTTTU −−−=

    Intersection of Case 1 & 2 is Least Upper BoundPlug In Intersection for C1 and C2 into U to get expression in terms of T1 and T2 only:(Substitute for both C1 and C2 in U expression and simplify)

    Let and so,

    I is the integer number of times that T1 occurs during T2f is the fractional time of the last release for T1 during T2, noting that if f =0, then T1 and T2 are harmonic, and therefore U=1, an uninteresting ideal case.Substituting I and f into the U expression above and simplifying, we get:

    12 /TTI = ( ) 1212 // TTTTf −=( )( )

    −−=

    12 /11

    TTffU

    ( )( )

    −−=

    12 /11

    TTffU

    ( ) ( )[ ] ( ) [ ]1212121221 /////1 TTTTTTTTTTU −−−=( ) ( )[ ] ( ) [ ]1212121221 ////1/1 TTTTTTTTTTU −−+−=

    (noting that 1+floor(N+/-0.d) = ceiling(N+/-0.d) when f non-zero)

    ( )( )( )ffTTU −−= 1/1 21 , Re-arranged to obtain:( ) ( ) ( )[ ] ( ) [ ]1212121221 ////1/1 TTTTTTTTTTU −−−−=

    So,

  • Sam Siewert 4

    RM LUB Derivation( )( )

    −−=

    12 /11

    TTffU Can also be expressed as:

    ( ) ( )

    −+

    −−=

    121212 ///11

    TTTTTTffU

    By adding and subtracting the same denominator term to get:

    ( )( )

    +−

    −=fIffU 11

    Now taking the derivative of U w.r.t. f, and solving for extreme, we get:( )( ) ( )( )

    ( )0

    11211/ 2

    2

    =+

    −−−+=

    fffffdfdU

    ( )( )

    +−

    −=fffU

    11

    2smallest I is 1, and LUB for Uoccurs when I is minimized, so:

    Solving for f, we get: ( )12 2/1 −=fAnd, plugging f back into U, we get: ( )122 2/1 −=U The RM LUB!

  • Detailed Algebra Notes

    Sam Siewert 5

  • Sam Siewert 6

    RM LUB Scenario for 2 Services(With T1=2, T2=3, We Show U=0.83 Worst-Case Graphically)

    T1= 2 T2= 3Case 1 Case 2C1 U C2 C1 U C2

    0 1 3 0 0.666667 20.1 0.983333 2.8 0.1 0.683333 1.90.2 0.966667 2.6 0.2 0.7 1.80.3 0.95 2.4 0.3 0.716667 1.70.4 0.933333 2.2 0.4 0.733333 1.60.5 0.916667 2 0.5 0.75 1.50.6 0.9 1.8 0.6 0.766667 1.40.7 0.883333 1.6 0.7 0.783333 1.30.8 0.866667 1.4 0.8 0.8 1.20.9 0.85 1.2 0.9 0.816667 1.1

    1 0.833333 1 1 0.833333 11.1 0.816667 0.8 1.1 0.85 0.91.2 0.8 0.6 1.2 0.866667 0.81.3 0.783333 0.4 1.3 0.883333 0.71.4 0.766667 0.2 1.4 0.9 0.61.5 0.75 0 1.5 0.916667 0.5

    RM LUB (T1=2, T2=3)

    00.05

    0.10.15

    0.20.25

    0.30.35

    0.40.45

    0.50.55

    0.60.65

    0.70.75

    0.80.85

    0.90.95

    1

    0 0.5 1 1.5

    C1

    U

    Given Case 1: ( ) ( ) ( ) [ ]122111221 //1/1// TTTTCTTTTU −+=

    ( )

    −+=

    2

    1211

    //11T

    TTTCUAnd Case 2:

    Sheet1

    T1=2T2=3

    Case 1Case 2

    C1UC2C1UC2

    01300.66666666672

    0.10.98333333332.80.10.68333333331.9

    0.20.96666666672.60.20.71.8

    0.30.952.40.30.71666666671.7

    0.40.93333333332.20.40.73333333331.6

    0.50.916666666720.50.751.5

    0.60.91.80.60.76666666671.4

    0.70.88333333331.60.70.78333333331.3

    0.80.86666666671.40.80.81.2

    0.90.851.20.90.81666666671.1

    10.8333333333110.83333333331

    1.10.81666666670.81.10.850.9

    1.20.80.61.20.86666666670.8

    1.30.78333333330.41.30.88333333330.7

    1.40.76666666670.21.40.90.6

    1.50.7501.50.91666666670.5

    Sheet1

    C1

    U

    RM LUB (T1=2, T2=3)

    Sheet2

    Sheet3

    Chart2

    00

    0.10.1

    0.20.2

    0.30.3

    0.40.4

    0.50.5

    0.60.6

    0.70.7

    0.80.8

    0.90.9

    11

    1.11.1

    1.21.2

    1.31.3

    1.41.4

    1.51.5

    C1

    U

    RM LUB (T1=2, T2=3)

    1

    0.6666666667

    0.9833333333

    0.6833333333

    0.9666666667

    0.7

    0.95

    0.7166666667

    0.9333333333

    0.7333333333

    0.9166666667

    0.75

    0.9

    0.7666666667

    0.8833333333

    0.7833333333

    0.8666666667

    0.8

    0.85

    0.8166666667

    0.8333333333

    0.8333333333

    0.8166666667

    0.85

    0.8

    0.8666666667

    0.7833333333

    0.8833333333

    0.7666666667

    0.9

    0.75

    0.9166666667

    Sheet1

    T1=2T2=3

    Case 1Case 2

    C1UC2C1UC2

    01300.66666666672

    0.10.98333333332.80.10.68333333331.9

    0.20.96666666672.60.20.71.8

    0.30.952.40.30.71666666671.7

    0.40.93333333332.20.40.73333333331.6

    0.50.916666666720.50.751.5

    0.60.91.80.60.76666666671.4

    0.70.88333333331.60.70.78333333331.3

    0.80.86666666671.40.80.81.2

    0.90.851.20.90.81666666671.1

    10.8333333333110.83333333331

    1.10.81666666670.81.10.850.9

    1.20.80.61.20.86666666670.8

    1.30.78333333330.41.30.88333333330.7

    1.40.76666666670.21.40.90.6

    1.50.7501.50.91666666670.5

    Sheet1

    C1

    U

    RM LUB (T1=2, T2=3)

    Sheet2

    Sheet3

  • Sam Siewert 7

    RM LUB Scenario for 2 Services(Showing U=0.83 Worst-Case Timing Diagram)

    T2T1

    C.I.S1

    S2

    Given Cases 1 and 2 again:T1=2, T2=3, C1=1, C2=1 at U=0.83Note: 5 out of 6 Time Units Used Over LCM Such That U=0.83, the RM LUB!

  • Sam Siewert 8

    RM FAQ• Where in the paper does it say that T must equal D?

    – T=D is in section 4 above Theorem 1 in Liu and Layland paper• Why does Floor(x.d)+1 = Ceiling(x.d)?, because if x=1 or any integer,

    this is not true.– Floor(x.d) + 1 = Ceiling(x.d) iff x is not an integer value, which is always

    true if T2 is not a multiple of T1• If T2 > T1, but T2 is a multiple of T1 (if T1 and T2 are harmonic), then

    U=1, and doesn’t this violate the RM LUB?– Yes, it does, but remember the RM LUB is only sufficient, not N&S, and

    therefore it will pessimistically fail service sets that can actually be scheduled

    – The RM LUB will correctly fail all service sets than in fact can’t be scheduled, so it is sufficient

    • Why Not Just Use EDF Scheduling Policy if it Can Achieve 100% Utility and Be Shown to Meet Deadlines?

    – What Happens When EDF is Overloaded?

  • Dynamic Priority• EDF [Earliest Deadline First] – When Ready

    Queue is Updated, the Scheduler Must Re-assign all Priorities According to Each Service’s Time Remaining to Deadline

    • LLF [Least Laxity First] - Ready Queue is Updated, the Scheduler Must Re-assign all Priorities According to Each Service’s (Time Remaining to Deadline - Execution Time Remaining)

    Sam Siewert 9

  • Sam Siewert 10

    Dynamic Priority Issues• Earliest Deadline First Policy (aka Deadline Driven Scheduling)

    – Can Be High Overhead - Every time the Ready Queue is Updated, the Scheduler Must Re-assign all Priorities According to Each Service’s Time Remaining to Deadline and Perform a Priority Preemption.

    – Overload Failure Modes Non-Deterministic - In an Overload Scenario, EDF Can Have Difficult to Predict and Cascading Multi-Service Failures

    • Overload with RM Policy is Deterministic - the Lowest Priority Service Will Fail First and The Number of Services Failing From Lowest Priority Up Can be Determined by Duration of Over-run and Priority of Over-running Service

    – Over-run Interference Has Known Impact on Lower Priority Services– Over-runs Will Be Preempted By Higher Priority Services if Allowed to Continue

    • Overload with EDF Policy is Non-Deterministic– Time to Deadline for an Over-running Service is Zero or Negative?– Over-running Service Will Maintain High Priority Based on Time to Deadline– Additional Services that Over-run Due to Interference Also Have Elevated Priority– Chaining Priority Amplification and Over-runs Can Cause Cascading Failure

    • Over-run Termination Policy May Help (Worst Case Interference Margin)

    – Difficult to Debug Dynamic Priority When Deadlines Are Missed

  • Sam Siewert 11

    RM Fixed Prio Overload

    Si

    Prio(Si+n) > Prioi (Si)

    Si = over-running service

    Prio(Si-n) < Prioi (Si)

    Si-1

    Si+1

  • Sam Siewert 12

    EDF Dynamic Prio Overload

    Si

    Si = over-running service

    Prio(Si-n) < Prioi (Si)

    Si-1

    Si-1

    Si-1 = over-running service

    Prio(Si-1-n) < Prioi (Si-1)

    Si-2

    Si-1

    Si-2 = over-running service

    Prio(Si-2-n) < Prioi (Si-2)

    Si-2

    Terminate Si = over-running service

    Terminate Si-1 = over-running service

  • Sam Siewert 13

    Dynamic Priority Issues Cont’d• Least Laxity First Policy

    – Can Be High Overhead - Every time the Ready Queue is Updated, the Scheduler Must Re-assign all Priorities According to Each Service’s (Time Remaining to Deadline - Execution Time Remaining) and Perform a Priority Preemption.

    – Execution Time Remaining Hard to Estimate - Compared to EDF, Least Laxity First is More Difficult to Implement Since Execution Time Remaining for All Services Must Be Estimated to Re-assign Priorities

    – Overload Failure Modes Better, But Still Non-Deterministic - In an Overload Scenario, LLF May Behave More Favorably Since it Encodes the Concept of Dispatching the Service with the Most Pressing Need for the CPU Resource (I.e. Remaining Execution Time is Factored In)

    • Over-run Invalidates Estimates of Execution Time Remaining• Suffers Same Potential Cascading Priority Amplification and Interference on

    Over-runs• Over-run Termination Policy May Help

    – Difficult to Debug Dynamic Priority When Deadlines Are Missed

  • Scheduling Feasibility Analysis with Cheddar

    See Notes - HERE

    Cheddar 2.1 for Windows (Tested for these slides)– Examples-2.1 for CEC450– Download of Cheddar-2.1 for win32

    Cheddar 3.0 for Windows [Current Download]– Examples-3.0 for CEC450 [Tested and

    ported from 2.1]– Cheddar 3.0 User’s Guide - Here

    Cheddar 3.0 for Linux (Bugs reported by students)– Run on VB-Linux [I have not tested]– Run on Jetson [I have not tested]

    Sam Siewert 14

    http://beru.univ-brest.fr/~singhoff/cheddar/ug/ug_v3/cheddar-r3.html

    User’s Guide for 3.X

    http://mercury.pr.erau.edu/%7Esiewerts/cec450/documents/Lectures/Lecture-Scheduling-Examples-with-Cheddar.pdfhttp://mercury.pr.erau.edu/%7Esiewerts/cec450/documents/Cheddar/Examples-2.1/http://mercury.pr.erau.edu/%7Esiewerts/cec450/documents/Cheddar/Cheddar-2.1-win32-bin.ziphttp://beru.univ-brest.fr/%7Esinghoff/cheddar/#Ref2http://mercury.pr.erau.edu/%7Esiewerts/cec450/documents/Cheddar/Examples-3.0/http://beru.univ-brest.fr/%7Esinghoff/cheddar/ug/ug_v3/cheddar-r3.htmlhttp://beru.univ-brest.fr/%7Esinghoff/cheddar/ug/ug_v3/cheddar-r3.htmlhttp://beru.univ-brest.fr/%7Esinghoff/cheddar/ug/ug_v3/cheddar-r3.html

  • Timing Diagramssched-example-simple-3-above-LUB-harmonic.xlsx

    Example Harmonic Service Freq f f0 multiple Period T LCM/T Notes: EDF tie favors higher frequencyS1 0.5 10 T1 2 C1 1 U1 0.5 LCM = 20 10 LLF tie favors higher frequencyS2 0.2 4 T2 5 C2 1 U2 0.2 4 Optimal tie breaker would favor least number of context switchesS3 0.1 2 T3 10 C3 2 U3 0.2 2 Metrics reference left edgeS4 (f0) 0.05 1 T4 20 C4 2 U4 0.1 U total = 1 1 TTD = Time to Deadline

    TR = Time Remaining to complete computationLLF = Least Laxity First (TTD - TR)

    RM Schedule 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20S1 1 2 3 4 5 6 7 8 9 10

    S2 1 2 3 4

    S3 1 1 2 2

    S4 1 1

    CS 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

    Fair Schedule 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20S1 1 MISS 3 MISS 5 6 7 8 9 FREE 10 FREE

    S2 1 2 3 4

    S3 1 1 2 2

    S4 1 ?? 1 ??

    CS 1 2 3 4 5 6 7 8 9 10 11 12 14 14 14 15 16 16 16 16

    Start at C.I. on Leftmost edgeShow Periods and Deadlines (Note if Different)Execution by Service According to PolicyShow Metric if Dynamic Priority (EDF, LLF)Count Context SwitchesShow Deadline Misses

    http://mercury.pr.erau.edu/%7Esiewerts/cec450/documents/Timing_Diagrams_Updated_2018/http://mercury.pr.erau.edu/%7Esiewerts/cec450/documents/Timing_Diagrams_Updated_2018/sched-example-simple-3-above-LUB-harmonic.xlsx

  • Sam Siewert 16

    Example #0 - Lots of Slack Time

    RM LUB = 3*(21/3-1) = 0.78

    Example 0 Service Period Freq f f0 multiple WCET UtilityS1 T1 2 0.5 7.5 C1 1 U1 50.00% LCM = 30S2 T2 10 0.1 1.5 C2 1 U2 10.00% LUB = 77.98%S3 T3 15 0.066667 1 C3 2 U3 13.33% Utot = 73.33% Slack 26.67% Slack+U 100.00%

    RM Schedule 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15S1

    S2

    S3

    SLACK SLACK SLACKEDF ScheduleS1

    S2

    S3

    Urgency (TTD)S1 2 X 2 X 2 X 2 X 2 X 2 X 2 X 2S2 10 9 X X X X X X X X X X X X XS3 15 14 13 12 11 10 X X X X X X X X X

    LLF ScheduleS1

    S2

    S3

    Laxity (TTD-TR)S1 1 X 1 X 1 X 1 X 1 X 1 X 1 X 1S2 9 8 X X X X X X X X X X X X XS3 13 12 11 10 10 9 X X X X X X X X X

  • Sam Siewert 17

    Example #1(RM Policy Failure)Example 1 Service Period Freq f f0 multiple WCET Utility

    S1 T1 2 0.5 3.5 C1 1 U1 50.00% LCM = 70S2 T2 5 0.2 1.4 C2 1 U2 20.00% LUB = 77.98%S3 T3 7 0.142857 1 C3 2 U3 28.57% Utot = 98.57%

    RM Schedule 1 2 3 4 5 6 7 8 9 10S1 ????????

    S2 ????????

    S3 LATE

    EDF ScheduleS1

    S2

    S3

    Urgency (TTD)S1 2 X 2 X 2 X 2 X 2 XS2 5 4 X X X 5 4 3 X XS3 7 6 5 4 3 2 X 7 6 5

    LLF ScheduleS1

    S2

    S3

    Laxity (TTD-TR)S1 1 X 1 X 1 X 1 X 1 XS2 4 3 X X X 4 3 2 X XS3 5 4 3 2 2 1 X 5 4 3

  • Sam Siewert 18

    Example #2 (High Load – S4 Over-runs)Example 2 Service Period Freq f f0 multiple WCET Utility

    S1 T1 2 0.5 6.5 C1 1 U1 50.00% LCM = 910S2 T2 5 0.2 2.6 C2 1 U2 20.00%S3 T3 7 0.142857 1.857143 C3 1 U3 14.29% LUB = 75.68%S4 T4 13 0.076923 1 C4 2 U4 15.38% Utot = 99.67%

    RM Schedule 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15S1 ????????

    S2

    S3

    S4 FAILURE

    EDF ScheduleS1

    S2

    S3

    S4

    Urgency (TTD)S1 2 X 2 X 2 X 2 X 2 X 2 X 2 XS2 5 4 X X X 5 X X X X 5 4 3 2S3 7 6 5 4 X X X 7 6 5 4 3 X XS4 13 12 11 10 9 8 7 6 5 4 X X X X

    LLF ScheduleS1

    S2

    S3

    S4

    Laxity (TTD-TR)S1 1 X 1 X 1 X 1 X 1 X 1 X 1 XS2 4 3 X X X 4 X X X X 4 3 2 1S3 6 5 4 3 X X X 6 5 4 X X X XS4 11 10 9 8 7 6 5 4 4 3 2 1 X X

  • Sam Siewert 19

    Example #3 (3 Policies with Common Schedule)Example 3 Services Freq f f0 multiple Period WCET Utility

    S1 0.333333 5 T1 3 C1 1 U1 0.33 LCM = 15S2 0.2 3 T2 5 C2 2 U2 0.4 LUB = 77.98%S3 0.066667 1 T3 15 C3 3 U3 0.2 Utot = 93.33% Slack 6.67% Slack+U 100.00%

    RM Schedule 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15S1 Slack

    S2

    S3

    EDF ScheduleS1

    S2

    S3Urgency (TTD)S1 3 X X 3 X X 3 X X 3 X X 3 X XS2 5 4 3 X X 5 4 3 X X 5 4 X X XS3 15 14 13 12 11 10 9 8 7 6 5 4 3 2 X

    LLF ScheduleS1

    S2

    S3Laxity (TTD-TR)S1 2 X X 2 X X 2 X X 2 X X 2 X XS2 3 2 2 X X 3 3 2 X X 3 3 X X XS3 12 11 10 9 8 8 7 6 5 5 4 3 3 2 X

  • Sam Siewert 20

    Example #4 (Harmonic 1, 4, 8x f0 – ∑U=1.0)Example 4 Services Freq f f0 multiple Period WCET Utility

    S1 0.5 8 T1 2 C1 1 U1 0.5 LCM = 16S2 0.25 4 T2 4 C2 1 U2 0.25 LUB = 77.98%S3 0.0625 1 T3 16 C3 4 U3 0.25 Utot = 100.00%

    RM Schedule 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16S1

    S2

    S3

    EDF ScheduleS1

    S2

    S3

    Urgerncy (TTD)S1 2 X 2 X 2 X 2 X 2 X 2 X 2 X 2 XS2 4 3 X X 4 3 X X 4 3 X X 4 3 X XS3 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

    LLF ScheduleS1

    S2

    S3

    Laxity (TTD-TR)S1 1 X 1 X 1 X 1 X 1 X 1 X 1 X 1 XS2 3 2 X X 3 2 X X 3 2 X X 3 2 X XS3 12 11 10 9 9 8 7 6 6 5 4 3 3 2 1 0

  • Sam Siewert 21

    Example #5 (Harmonic 1, 2, 5x f0 – ∑U=1.0)Example 5 Service Period Freq f f0 multiple WCET Utility

    S1 T1 2 0.5 5 C1 1 U1 0.5 LCM = 10S2 T2 5 0.2 2 C2 2 U2 0.4 LUB = 77.98%S3 T3 10 0.1 1 C3 1 U3 0.1 Utot = 100.00%

    RM Schedule 1 2 3 4 5 6 7 8 9 10S1

    S2

    S3

    EDF ScheduleS1

    S2

    S3

    Urgency (TTD)S1 2 X 2 X 2 X 2 X 2 XS2 5 4 3 2 X 5 4 3 X XS3 10 9 8 7 6 5 4 3 2 1

    LLF ScheduleS1

    S2

    S3

    Laxity (TTD-TR)S1 1 X 1 X 1 X 1 X 1 XS2 3 2 2 1 X 3 3 2 X XS3 9 8 7 6 5 4 3 2 1 0

  • Reminder - HarmonicsA harmonic of a wave is a component frequency of the signal that is an integer multiple of the fundamental frequency, i.e. if the fundamental frequency is f, the harmonics have frequencies 2f, 3f, 4f, . . . etc. The harmonics have the property that they are all periodic at the fundamental frequency, therefore the sum of harmonics is also periodic at that frequency. As multiples of the fundamental frequency, successive harmonics can be found by repeatedly adding the fundamental frequency. For example, if the fundamental frequency (first harmonic) is 25 Hz, the frequencies of the next harmonics are: 50 Hz (2nd harmonic), 75 Hz (3rd harmonic), 100 Hz (4th harmonic) etc.

    Sam Siewert 22

    https://en.wikipedia.org/wiki/Harmonic

    https://en.wikipedia.org/wiki/Harmonic

    CEC 450�Real-Time SystemsDetailed Algebra Notes (p. 82)RM LUB DerivationRM LUB DerivationDetailed Algebra NotesRM LUB Scenario for 2 Services�(With T1=2, T2=3, We Show U=0.83 Worst-Case Graphically)RM LUB Scenario for 2 Services�(Showing U=0.83 Worst-Case Timing Diagram)RM FAQDynamic PriorityDynamic Priority IssuesRM Fixed Prio OverloadEDF Dynamic Prio OverloadDynamic Priority Issues Cont’dScheduling Feasibility Analysis with CheddarTiming Diagrams�sched-example-simple-3-above-LUB-harmonic.xlsxExample #0 - Lots of Slack TimeExample #1(RM Policy Failure)Example #2 (High Load – S4 Over-runs)Example #3 (3 Policies with Common Schedule)Example #4 (Harmonic 1, 4, 8x f0 – ∑U=1.0)Example #5 (Harmonic 1, 2, 5x f0 – ∑U=1.0)Reminder - Harmonics