Presentation is loading. Please wait.

Presentation is loading. Please wait.

Priority Inheritance and Priority Ceiling Protocols L. Sha, R. Rajkumar, and J. P. Lehoczky, "Priority Inheritance Protocols: An Approach to Real-Time.

Similar presentations


Presentation on theme: "Priority Inheritance and Priority Ceiling Protocols L. Sha, R. Rajkumar, and J. P. Lehoczky, "Priority Inheritance Protocols: An Approach to Real-Time."— Presentation transcript:

1 Priority Inheritance and Priority Ceiling Protocols L. Sha, R. Rajkumar, and J. P. Lehoczky, "Priority Inheritance Protocols: An Approach to Real-Time Synchronization", IEEE Transactions on Computers, Vol. 39, No. 9, Sept "Priority Inheritance Protocols: An Approach to Real-Time Synchronization",

2 Priority Inversion A high priority task is blocked due to a low priority task How can it happen? Mutex for shared resource access Non-preemptive subsystem access Network System bus Secondary storage

3 Mutual Exclusion via Semaphores Ensure only one task/process is in the critical section wait(S) to get access to semaphore S signal(S) to release S Example: producer consumer Producer() {. wait(S) critical section /* create data & increment pointer */ signal(S). }

4 Priority Inversion Source of the figure: Chenyang Lu, Washington University Saint Louis

5 Unbounded Priority Inversion

6 What really happened on Mars? Repeated resets in the Mars Pathfinder The Mars Pathfinder mission was widely proclaimed as "flawless" in the early days after its July 4th, 1997 landing on the Martian surface.... But a few days into the mission, not long after Pathfinder started gathering meteorological data, the spacecraft began experiencing total system resets, each resulting in losses of data. The press reported these failures in terms such as "software glitches" and "the computer was trying to do too many things at once".... For a full story, visit Pathfinder.html

7 Pathfinder Incident Classical priority inversion problem due to shared system bus! Source of the figure: Damir Isovic, Malardaren University, Sweden

8 Priority Inheritance Inherit the priority of the blocked high priority task

9 Priority Inheritance Protocol (PIP) If T L blocks a higher proirity task T H, priority(T L ) priority(T H ) When T L releases a semaphore: Return to its normal priority if it doesnt block any task Otherwise, set priority(P L ) highest priority of the tasks blocking on a semaphore held by T L Transitive T 1 blocked by T 2 : priority(T 2 ) priority(T 1 ) T 2 blocked by T 3 : priority(T 3 ) priority(T 1 )

10 Chained Blocking: Problem of PIP In the worst case, the highest priority task T 1 can be blocked by N lower priority tasks in the system when T 1 has to access N semaphores to finish the execution! Source of the figure: Damir Isovic, Malardaren University, Sweden

11 Response Time Analysis of RMS with PIP For RMS schedulability test, ensure that: i=1, N (C i /T i + B i /T i ) n(2 1/n - 1), 1 i n B i is the the longest priority inversion time that could be experienced by T i B i = CS i + CS i CS k where CS i, CS i+1,..., CS k are the critical sections by which lower priority tasks could block T i Sufficient but not necessary because the priority due to contention for CS may not happen in reality

12 Priority Ceiling Protocol (PCP) Avoid chained blocking Guarantee a task is blocked by at most one lower priority task No deadlock Assumptions Each task is associated with a fixed priority

13 PCP Each semaphore has the fixed priority ceiling ceiling(S) = highest priority among all the tasks that will request S How it works: T i can access a semaphore S if S is not already allocated to any other task; and Priority of T i is higher than the current processor ceiling = max(priority ceilings of all the semaphores allocated to tasks other than T i )

14 PCP Ceiling(S1) = 1 (high) Ceiling(S2) = 2 (medium) Ceiling(S3) = 2 (medium) Source of the figure: Damir Isovic, Malardaren University, Sweden No chained blocking!

15 Schedulability of RMS with PCP Consider blocking time: i=1, N (C i /T i + B i /T i ) n(2 1/n - 1), 1 i n B i = max(CS i, CS i+1,..., CS k ) where CS i, CS i+1,..., CS k are the critical sections that can block T i

16 Scheduling Aperiodic + Periodic Tasks

17 Task Arrival Patterns Periodic Sporadic Aperiodic but minimum interarrival time is known Worst case Every sporadic job always arrives at its minimum interarrival time Treat as periodic tasks Utilization bound or response time analysis If schedulable for the worst case, schedulable for all the other cases Aperiodic No limitations on interarrival times Scheduling algorithms we have seen so far do not apply

18 Aperiodic Deadlines Soft: Not much to do in terms of scheduling Firm Deadline & WCET are given Start a firm deadline task only if it will finish by the deadline Lets discuss several hybrid scheduling algorithms that use RMS for periodic task scheduling Several approaches to scheduling aperiodic tasks

19 Background Scheduling Schedule periodic tasks first Schedule aperiodic tasks only if theres no periodic task Periodic tasks CPU Aperiodic tasks High priority queue Low priority queue RMS FCFS, EDF, etc.

20 Background Scheduling with RMS Task set: T 1 (2, 6), T 2 (4,10) where T i =(C i, P i ) Schedulable since 2/6 + 4/10 = 0.73 < 2(2 1/2 - 1) = 0.82 T1T1 T2T T 1,1 T 1,2 T 2,1 Idle Schedule aperiodic tasks here

21 Polling Server Use a periodic task to serve aperiodic tasks Period: P s Capacity: C s Algorithm Release the server at every period P s Serve any pending aperiodic task Suspend itself, i.e., capacity = 0, if It consumed C s ; or There no pending aperiodic request Replenish capacity, i.e., capacity = C s, at the next period

22 Schedulability of Polling Server Aperiodic tasks have no impact on periodic ones There can be multiple servers n periodic tasks & m polling servers are schedulable if U p + U s U(m+n) Problem: If an aperiodic request arrives right after the server period, it has to wait until the next period Long response time Response time of an aperiodic request with execution time C a is P s + C a /C s P s

23 Deferrable Server (DS) Preserve the unused capacity until the end of the current period Reduce response time to aperiodic requests DS affects the schedulability of periodic tasks DS schedulability RM

24 Priority Exchange Server Server has the highest priority at the beginning If theres no aperiodic request to serve right now, preserve capacity for lower priority tasks execution time Replenish the capacity at the next period

25 Optimal? No optimal algorithm exists to minimize the response time! Other servers with RMS Sporadic server: Replinish capacity only after aperiodic request execution Slack stealing: No periodic server, but slack stealer tries to steal time from periodic tasks


Download ppt "Priority Inheritance and Priority Ceiling Protocols L. Sha, R. Rajkumar, and J. P. Lehoczky, "Priority Inheritance Protocols: An Approach to Real-Time."

Similar presentations


Ads by Google