Skip to content
Related Articles

Related Articles

Priority Inheritance Protocol (PIP) in Synchronization
  • Last Updated : 25 May, 2020

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.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :