What is priority inversion problem in inter-process communication? How to solve it?

Priority inversion problem:

-> Priority inversion means the execution of a high priority process/thread is blocked by a lower priority process/thread.
-> Consider a computer with two processes, H having high priority and L having low priority.
-> The scheduling rules are such that H runs first then L will run.
-> At a certain moment, L is in critical region and H becomes ready to run (e.g. I/O operation complete).
-> H now begins busy waiting and waits until L will exit from critical region.
-> But H has highest priority than L so CPU is switched from L to H.
-> Now L will never be scheduled (get CPU) until H is running so L will never get chance to leave the critical region so H loops forever. This situation is called priority inversion problem.

Solving priority inversion problem solution:

-> Execute the critical region with masked (disable) interrupt. Thus the current process cannot be preempted. 
-> Determine the maximum priority among the process that can execute this critical region, and then make sure that all processes execute the critical region at this priority. Since now competing process have the same priority, they can’t preempt other.

-> A priority ceiling: With priority ceilings, the shared Mutex process (that runs the operating system code) has a characteristic (high) priority of its own, which is assigned to the task locking the Mutex. This works well, provided the other high priority task(s) that tries to access the Mutex does not have a priority higher than the ceiling priority.

-> Priority inheritance: Under the policy of priority inheritance, whenever a high priority task has to wait for some resource shared with an executing low priority task, the low priority task is temporarily assigned the priority of the highest waiting priority task for the duration of its own use of the shared resource, thus keeping medium priority tasks from preempting the (originally) low priority task, and thereby affecting the waiting high priority task as well. Once the resource is released, the low priority task continues at its original priority level.

Post a Comment

GTU done 2018 |