Carnegie Mellon University Software Engineering Institute Rate Monotonic Analysis Introduction Periodic tasks Extending basic theory Synchronization and priority inversion Aperiodic servers Case study: BSY-1 Trainer 1 Extending Basic Theory Carnegie Mellon University Software Engineering Institute Extensions to Basic Theory This section extends the schedulability tests to address • nonzero task switching times • preperiod deadlines • interrupts and non-rate-monotonic priorities 2 Extending Basic Theory Carnegie Mellon University Software Engineering Institute Modeling Task Switching as Execution Time Ci + 2S Ui = 100 0 τ1 Ti C1 τ2 C1 C2 C1 200 C1 C2 C2 τ3 S 40 C1 time 40 T1 T2 2T1 Two scheduling actions per task (start of period and end of period) 3 Extending Basic Theory S S C2 S S Carnegie Mellon University Software Engineering Institute Modeling Preperiod Deadlines Suppose task τ, with compute time C and period T, has a preperiod deadline D (i.e. D < T ). Compare total utilization to modified bound: U total Cn C1 = ------ + ... + ------ ≤ U(n, ∆ i) Tn T1 where ∆i is the ratio of Di to Ti . 1 / n – 1) + 1 – ∆ , ( ( ) n 2∆ i i U(n, ∆ i) = ∆ , ∆ ≤ 1--i 2 i 4 Extending Basic Theory 1 --- < ∆ i ≤ 1.0 2 Carnegie Mellon University Software Engineering Institute Schedulability with Interrupts Interrupt processing can be inconsistent with rate monotonic priority assignment. • interrupt handler executes with high priority despite its period • interrupt processing may delay execution of tasks with shorter periods Effects of interrupt processing must be taken into account in schedulability model. Question is: how to do that? 5 Extending Basic Theory Carnegie Mellon University Software Engineering Institute Example: Determining Schedulability with Interrupts Task τ1: Task τ2: Task τ3: Task τ4: C 20 40 60 40 T 100 150 200 350 τ3 is an interrupt handler 6 Extending Basic Theory U 0.200 0.267 0.300 0.115 Carnegie Mellon University Software Engineering Institute Example: Execution with Rate Monotonic Priorities 0 τ1 τ2 τ3 τ4 7 Extending Basic Theory 100 200 300 400 Carnegie Mellon University Software Engineering Institute Example: Execution with an Interrupt Priority 0 τ1 τ2 Interrupt τ4 8 Extending Basic Theory 100 200 300 400 Carnegie Mellon University Software Engineering Institute Resulting Table for Example 9 Extending Basic Theory Task (i) Period (T) Execution Time (C) Priority (P) Deadline (D) τ3 τ1 τ2 τ4 200 100 150 350 60 20 40 40 HW High Medium Low 200 100 150 350 Carnegie Mellon University Software Engineering Institute UB Test with Interrupt Priority Test is applied to each task. Determine effective utilization (fi) of each task i using C j Ci 1 f i = ∑ ----- + ----- + ---- ∑ C k T T i T i k ∈ H1 j ∈ Hn j Preemption from tasks that can hit more than once (with period less than Di) Preemption from tasks that can hit only once (with period greater than Di) Execution of task under test Compare effective utilization against bound, U(n). • n = num(Hn) + 1 • num(Hn) = the number of tasks in the set Hn 10 Extending Basic Theory Carnegie Mellon University Software Engineering Institute UB Test with Interrupt Priority: τ3 For τ3, no tasks have a higher priority: H = Hn = H1 = { }. f3 C3 = 0 + ------ + 0 ≤ U ( 1 ) T3 Note that utilization bound is U(1): num(Hn) = 0. Plugging in numbers: C3 60 f 3 = ------ = --------- = 0.3 < 1.0 200 T3 11 Extending Basic Theory Carnegie Mellon University Software Engineering Institute UB Test with Interrupt Priority: τ1 To τ1, τ3 has higher priority: H = {τ3}; Hn = { }; H1 = {τ3}. C1 1 f 1 = 0 + ------ + ----- ∑ C k ≤ U ( 1 ) T1 T1k = 3 Note that utilization bound is U(1): num(Hn) = 0. Plugging in the numbers: C1 C3 20 60 f 1 = ------ + ------ = --------- + --------- = 0.800 < 1.0 100 100 T1 T1 12 Extending Basic Theory Carnegie Mellon University Software Engineering Institute UB Test with Interrupt Priority: τ2 To τ2: H = {τ1,τ3}; Hn = {τ1}; H1 = {τ3}. C j C2 1 f 2 = ∑ ----- + ------ + ----- ∑ C k T T2 T2k = 3 j=1 j ≤ U ( 2) Note that utilization bound is U(2): num(Hn) = 1. Plugging in the numbers: C1 C2 C3 20 40 60 f 2 = ------ + ------ + ------ = --------- + --------- + --------- = 0.867 100 150 150 T1 T2 T2 13 Extending Basic Theory > 0.828 Carnegie Mellon University Software Engineering Institute UB Test with Interrupt Priority: τ4 To τ2: H = {τ1,τ2,τ3}; Hn = {τ1,τ2,τ3}; H1 = { }. C j C4 f 4 = ∑ ----- + ------ + 0 T T4 j = 1, 2, 3 j ≤ U ( 4) Note that utilization bound is U(4): num(Hn) = 3. Plugging in the numbers: C1 C2 C3 C4 f 4 = ------ + ------ + ------ + -----T1 T2 T3 T4 20 40 60 40 = --------- + --------- + --------- + --------- = 0.882 100 150 200 350 14 Extending Basic Theory > 0.756 Carnegie Mellon University Software Engineering Institute Exercise: Schedulability with Interrupts Given the following tasks: Task (i) Period (T) Execution Time (C) Priority (P) Deadline (D) τint τ1 τ2 6 4 10 2 1 1 HW High Low 6 3 10 Use the UB test to determine which tasks are schedulable. 15 Extending Basic Theory Carnegie Mellon University Software Engineering Institute Solution: Schedulability with Interrupts C int --------- ≤ U ( 1 ) T int 0.334 < 1.0 {H1} C 1 C int ------ + --------- ≤ U ( 1, .75 ) T1 T1 0.250 + 0.500 = 0.750 = U ( 1, .75 ) {Hn} C int C 1 C 2 --------- + ------ + ------ ≤ U ( 3 ) T int T 1 T 2 0.334 + 0.250 + 0.100 = 0.684 < 0.779 16 Extending Basic Theory Carnegie Mellon University Software Engineering Institute Basic Theory: Where Are We? We have shown how to handle • task context switching time: include 2S within C • preperiod deadlines: change bound to U(n, ∆i) • non-rate-montonic priority assignments We still must address • task interactions • aperiodic tasks We still assume • single processor • priority-based scheduling • tasks do not suspend themselves 17 Extending Basic Theory Carnegie Mellon University Software Engineering Institute Other Important Issues Mode change Multiprocessor systems Priority granularity Overload Spare capacity assessment Distributed systems Post-period deadlines 18 Extending Basic Theory