130 likes | 238 Views
Resource management and priorities in Real-Time Systems. Jan Lindström. Contents. Objectives Resources Priority inversion problem Methods to avoid priority inversion Priority inheritance protocol Summary. Objectives. What are shared resources ?
E N D
Resource management and priorities in Real-Time Systems Jan Lindström Real-Time Systems, J. Lindström
Contents • Objectives • Resources • Priority inversion problem • Methods to avoid priority inversion • Priority inheritance protocol • Summary Real-Time Systems, J. Lindström
Objectives • What are shared resources ? • Why resources influence scheduling of the real-time tasks ? • What is priority inversion problem ? • What methods there are to avoid priority inversion problem ? • How does priority inheritance work ? Real-Time Systems, J. Lindström
Shared resources • Several tasks access software and hardware objects where mutual exclusion is necessary. • Resource allocated to one job at time. Once allocated, held by the job until no longer needed. • Examples: semaphores, locks, servers,… • Operations: lock(resource) --- <critical section>--- unlock(resource) Real-Time Systems, J. Lindström
Priority inversion problem lock(R) unlock(R) lock(R) Real-Time Systems, J. Lindström
Pre-emption of tasks in their critical sections • Negative effect on schedulability and predictability. • Traditional resource management algorithms fail. ( They decouple resource management decisions from scheduling decisions). Real-Time Systems, J. Lindström
Mars Pathfinder • Landed 4.7.1997 • Experiences software glitches. • http://research.microsoft.com/~mbj/Mars_Pathfinder/Mars_Pathfinder.html Real-Time Systems, J. Lindström
Priority inversion in Mars Pathfinder Real-Time Systems, J. Lindström
Avoiding priority inversion • Non-preemptive critical sections • Causes unpredictable waiting time. • Usable only to short critical sections. • Entry protocols for critical sections • Priority Inheritance Protocol. • Priority Ceiling Protocol. Real-Time Systems, J. Lindström
Priority inheritance protocol Under this protocol, if a higher priority task TH is blocked by a lower priority task TL, because TL is currently executing critical section needed by TH, TL temporarily inherits the priority of TH. When blocking ceases (i.e., TL exits the critical section), TL resumes its original priority. Unfortunately, priority inheritance may lead to deadlock. Real-Time Systems, J. Lindström
Example of priority inheritance blocked T1 T2 T3 prio(T1) > prio(T2) > prio(T3) without priority inheritance T1 T2 T3 with priority inheritance prio(T3) = prio(T1) Real-Time Systems, J. Lindström
Complexity of scheduling • ”When there are mutual exclusion constraints in a system, it is impossible to find an optimal on-line scheduling algorithm (unless it is clairvoyant).” (Mok, 1983) • ”The problem of deciding feasibility for set of periodic tasks which use semaphores to enforce mutual exclusion is NP-hard.” (Mok, 1983). Real-Time Systems, J. Lindström
Summary • Critical sections have negative effect on schedulabitity and predictability. • Critical sections can cause priority inversion problem. • Priority inheritance can control priority inversion. Real-Time Systems, J. Lindström