Download presentation
Presentation is loading. Please wait.
Published byLora Summers Modified over 9 years ago
1
Real Time Operating Systems Schedulability - Part 3 Course originally developed by Maj Ron Smith 10/24/2015Dr Alain Beaulieu1
2
Outline Review of Task Model Assumptions Removing Task Independence Review Priority Inversion & Priority Inheritance Time-Demand Analysis & Blocking Time-Demand Analysis & Priority-Ceiling Protocols 10/24/2015 Dr Alain Beaulieu
3
Review of Task Model Assumptions single processor fixed number of tasks all tasks are periodic context switch times are negligible all tasks are preemptable all tasks are independent task priorities are fixed X X X X - Our schedulability analysis can not handle deviation from the assumption. - Our schedulability analysis (to date) can handle deviation from the assumption. 10/24/2015 Dr Alain Beaulieu
4
Removing Task Independence The assumption that tasks are independent is unreasonable for any meaningful system tasks typically share common resources (R k ) through the use of semaphores and monitors tasks often must synchronize This implies that a task(s) may suspend pending some future event which is dependent upon one or more other tasks How will this dependence affect schedulability? 10/24/2015 Dr Alain Beaulieu
5
Recall : Priority Inversion Priority inversion can occur when a high and a low priority task share a common resource the low priority task gets exclusive access to the shared resource the higher priority task preempts the lower priority task but is blocked pending release of the shared resource meanwhile a medium priority task preempts the lower priority task, thus further delaying the execution of the high priority task since the medium task is guaranteed priority service over the blocked higher priority task => priority inversion 10/24/2015 Dr Alain Beaulieu
6
Recall: Priority Inheritance & Scheduling Simple priority inheritance is a technique for avoiding priority inversion each task has a dynamic priority, equal to the maximum of its own static priority and any it inherits due to blocking higher priority tasks this effectively blocks any “medium” priority tasks Theorem : if priority inheritance is employed, the number of times a task can be blocked by lower priority tasks is limited by the lessor of: K - the number of blocking critical sections; or n - the number of lower priority tasks 10/24/2015 Dr Alain Beaulieu
7
Blocking Time Defined From the previous theorem, the block time of task i is defined to be -> b i = usage(k, i ) e CS (k)(1) where usage(k, i) = 1 if resource k is used by at least one task with priority < i and at least one task (including i ) with priority ≥ i = 0 otherwise and e CS (k) = execution time of the k th critical section k=1 K 10/24/2015 Dr Alain Beaulieu
8
Blocking Time Example Given the 4 task, 2 resource system described below, determine the blocking time of each task using equation (1) Tii12213443Tii12213443 k j e cs (k j )used by tasks 10.51,4 20.251,2,3 Tasks Resource Utilization 10/24/2015 Dr Alain Beaulieu
9
Time-Demand Analysis with Blocking Yielding a more general response time for task i: w i * = e i + b i + I i * Note: this equation is now pessimistic (sufficient but not necessary) Why? Although employing simple priority inheritance will bound the number of blocks a task may experience, recall that it does not prevent transitive blocking nor deadlock 10/24/2015 Dr Alain Beaulieu
10
Blocking Exercise TasksResources Taske i p i D i k e CS (k) used by 1 3257 1 21,3,4 2212- 2 42,4 3517- 4624- assume DM priority scheduling simple priority inheritance is employed determine the schedulability of the tasks 10/24/2015 Dr Alain Beaulieu
11
Blocking Exercise - Solution (1) Task i e i p i D i k e CS (k) used by 1 13257 1 21,3,4 2 2212- 2 42,4 3 3517- 4 4624- use DMPO simple priority inheritance is employed determine the schedulability of the tasks 10/24/2015 Dr Alain Beaulieu
12
Blocking Exercise - Solution (2) w 1 = e 1 + b 1 + I 1 where b 1 = usage(1,1) e CS (1) + usage(2,1) e CS (2) = (1)(2) + (0)(4) = 2 andI 1 = 0 (there are no higher priorities) therefore w 1 = 3 + 2 + 0 = 5 and w 1 D 1 10/24/2015 Dr Alain Beaulieu
13
Blocking Exercise - Solution (3) w 2 = e 2 + b 2 + I 2 where b 2 = usage(1,2) e CS (1) + usage(2,2) e CS (2) = (1)(2) + (1)(4) = 6 and w 2 = 2 + 6 + Σ w 2 / p j e j using recursionw 2 0 = 2 w 2 1 = 8 + w 2 0 /25 3 = 11 w 2 2 = 8 + w 2 1 /25 3 = 11 therefore w 2 = 11 andw 2 D 2 10/24/2015 Dr Alain Beaulieu
14
Blocking Exercise - Solution (4) w 3 = e 3 + b 3 + I 3 where b 3 = usage(1,3) e CS (1) + usage(2,3) e CS (2) = (1)(2) + (1)(4) = 6 and w 3 = 5 + 6 + Σ w 3 / p j e j againw 3 0 = 5 w 3 1 = 11 + w 3 0 /25 3 + w 3 0 /12 2 = 16 w 3 2 = 11 + w 3 1 /25 3 + w 3 1 /12 2 = 18 w 3 3 = 11 + w 3 2 /25 3 + w 3 2 /12 2 = 18 therefore w 3 = 18 (> 17) - the system is not scheduleable! 10/24/2015 Dr Alain Beaulieu
15
Now Recall: Ceiling Priority Protocols A class of resource sharing algorithms entitled Ceiling Priority Protocols are introduced as an alternative to simple priority inheritance to: eliminate transitive blocking for any given task only a single blocking event may occur eliminate deadlock a task holding one resource may not claim another resource that could lead to circular lock/requests 10/24/2015 Dr Alain Beaulieu
16
Blocking & Ceiling Priority Protocols Given that the ceiling priority protocols guarantee that only a single instance of blocking can occur (with respect to task i’s execution), We can use the modified blocking time equation: b i = max {usage(k, i ) e CS (k) } k=1 K 10/24/2015 Dr Alain Beaulieu
17
CPP Exercise - Same system as before TasksResources Taske i p i D i k e CS (k) used by 1 3257 1 21,3,4 2212- 2 42,4 3517- 4624- ** This is the exact same system as previously in the lecture, except the system uses a ceiling priority protocol Determine if the system is schedulable 10/24/2015 Dr Alain Beaulieu
18
CPP Exercise – Solution (1) The following changes must be accounted for with the use of a ceiling priority protocol first b 2 = max { usage(1,2) e CS (1), usage(2,2) e CS (2) } = 4 andb 3 = max { usage(1,3) e CS (1), usage(2,3) e CS (2) } = 4 then w 1 = 5 (no change) and w 2 = 9 (less response time) but check out w 3 10/24/2015 Dr Alain Beaulieu
19
CPP Exercise – Solution (2) w 3 = e 3 + b 3 + I 3 with new b 3 = 4 and w 3 = 5 + 4 + Σ w 3 / p j e j againw 3 0 = 5 w 3 1 = 9 + w 3 0 /25 3 + w 3 0 /12 2 = 14 w 3 2 = 9 + w 3 1 /25 3 + w 3 1 /12 2 = 16 w 3 3 = 9 + w 3 2 /25 3 + w 3 2 /12 2 = 16 therefore w 3 = 16 17 and the system may now be scheduleable! But now you must check w 4 10/24/2015 Dr Alain Beaulieu
20
CPP Exercise – Solution (3) w 4 = e 4 + b 4 + I 4 where b 4 = max{ usage(1,4) e CS (1), usage(2,4) e CS (2)} = max{ (0)(2), (0)(4) } = 0 (lowest priority task) and w 4 = 6 + 0 + Σ w 4 / p j e j againw 4 0 = 6 w 4 1 = 6 + w 4 0 /25 3 + w 4 0 /12 2 + w 4 0 /17 5 = 16 w 4 2 = 6 + w 4 1 /25 3 + w 4 1 /12 2 + w 4 1 /17 5 = 18 w 4 3 = 6 + w 4 2 /25 3 + w 4 2 /12 2 + w 4 2 /17 5 = 23 w 4 4 = 6 + w 4 3 /25 3 + w 4 3 /12 2 + w 4 3 /17 5 = 23 therefore w 4 = 23 24 & the system is now scheduleable! 10/24/2015 Dr Alain Beaulieu
21
References [1] Liu, J.W.S., “Real-Time Systems”, Prentice-Hall, 2000. [2] Burns, A. and Wellings, A., “Real-Time Systems and Programming Languages”, Chapter 13, Addison Wesley, 1997 [3] TimeSys Corp, “The Concise Handbook of Real-Time Systems”, Version 1.0, 1999 10/24/2015 Dr Alain Beaulieu
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.