Priority Inheritance Protocol (PIP) in Synchronization

Prerequisite – Introduction of Process Synchronization
Priority Inheritance Protocol (PIP) is a technique which is used for sharing critical resources among different tasks. This allows the sharing of critical resources among different without the occurrence of unbounded priority inversions.

Basic Concept of PIP :
The basic concept of PIP is that when a task goes through priority inversion, the priority of the lower priority task which has the critical resource is increased by the priority inheritance mechanism. It allows this task to use the critical resource as early as possible without going through the preemption. It avoids the unbounded priority inversion.

Working of PIP :

  • When several tasks are waiting for the same critical resource, the task which is currently holding this critical resource is given the highest priority among all the tasks which are waiting for the same critical resource.
  • Now after the lower priority task having the critical resource is given the highest priority then the intermediate priority tasks can not preempt this task. This helps in avoiding the unbounded priority inversion.
  • When the task which is given the highest priority among all tasks, finishes the job and releases the critical resource then it gets back to its original priority value (which may be less or equal).
  • If a task is holding multiple critical resources then after releasing one critical resource it can not go back to it original priority value. In this case it inherits the highest priority among all tasks waiting for the same critical resource.
If the critical resource is free then
       allocate the resource
If the critical resource is held by higher priority task then
       wait for the resource
If the critical resource is held by lower priority task
     {    
       lower priority task is provided the highest priority
       other tasks wait for the resource
     } 

Advantages of PIP :
Priority Inheritance protocol has the following advantages:

  • It allows the different priority tasks to share the critical resources.
  • The most prominent advantage with Priority Inheritance Protocol is that it avoids the unbounded priority inversion.

Disadvantages of PIP :
Priority Inheritance Protocol has two major problems which may occur:



  • Deadlock –
    There is possibility of deadlock in the priority inheritance protocol.

    For example, there are two tasks T1 and T2. Suppose T1 has the higher priority than T2. T2 starts running first and holds the critical resource CR2.

    After that, T1 arrives and preempts T2. T1 holds critical resource CR1 and also tries to hold CR2 which is held by T2. Now T1 blocks and T2 inherits the priority of T1 according to PIP. T2 starts execution and now T2 tries to hold CR1 which is held by T1.

    Thus, both T1 and T2 are deadlocked.

  • Chain Blocking –
    When a task goes through priority inversion each time it needs a resource then this process is called chain blocking.

    For example, there are two tasks T1 and T2. Suppose T1 has the higher priority than T2. T2 holds the critical resource CR1 and CR2. T1 arrives and requests for CR1. T2 undergoes the priority inversion according to PIP.

    Now, T1 request CR2, again T2 goes for priority inversion according to PIP.

    Hence, multiple priority inversion to hold the critical resource leads to chain blocking.

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.