Skip to content
Related Articles

Related Articles

Improve Article

Types of Priority Inversions under PCP

  • Last Updated : 29 May, 2020

When a set of tasks share the critical resources using Priority Ceiling Protocol then it may go through different types of priority inversions. The types of priority inversions through which tasks go while sharing critical resources using PCP are as following:

1. Direct Inversion :
When a higher priority task waits for a lower priority task to release the critical resource which lower priority task is holding and higher priority task needs this critical resource, then direct inversion occurs.

Suppose there are two tasks T1 and T2 where T2 is having higher priority than T1. T1 (lower priority task) is holding a critical resource CR. Now T2 (higher priority task) needs this resource but T2 will have to wait until T1 executes and releases the critical resource CR. Here it can be seen that in this inversion a lower priority task makes higher priority task to go into inversion by holding the resource needed by higher priority task.

2. Inheritance-Related Inversion :
When a lower priority task is holding a critical resource and a higher priority task is waiting for this critical resource, then the priority of the lower priority task is set to the equal of priority of waiting higher priority task using the inheritance technique under PCP. As a result of this, the intermediate priority tasks which do not need the critical resource go into inheritance-related inversion.

Suppose there are three tasks T1, T2 and T3. The priority of these tasks is as T1 > T2 > T3. T1 and T3 both need the critical resource CR while T2 has no requirement of critical resource. At some point of time, T3 (lowest priority task) acquires the critical resource CR. Now T1 (highest priority task) needs the critical resource CR and requests for it. Now by inheritance clause T3 gets its priority equal to priority of T1. Therefore, T2, which do not need the critical resource, do not get executed as a result of raised priority of T3. Hence task T2 goes under the inheritance-related inversion.

3. Avoidance-Related Inversion :
When a task needs the critical resource, its priority is compared with the Current System Ceiling (CSC). The task is allotted the critical resource if the priority of task is greater than the value of CSC. When the critical resource is not allotted to any task i.e critical resource is free and a task whose priority is less than CSC is requesting for this critical resource, is denied access to this critical resource. Task having higher priority than currently executing task and greater than CSC and requests a critical resource which is free, is said to go under avoidance-related inversion. It is also called as priority ceiling-related inversion as a higher priority task is allotted the critical resource not because the requested critical resource is held by another task but because its priority is less than CSC. It is also called as deadlock avoidance inversion as higher priority task is blocked for a critical resource that is not used y any other task.

Suppose there are two tasks T1 and T2 where T2 is having higher priority than T2. Both need critical resources CR1 and CR2. T1 (lower priority task) is currently using critical resource CR1. Now T2 (higher priority task) requests to use the critical resource CR2 but access is denied as its priority is less than CSC. Not allowing T2 to use the CR2 blocks the possibility that T1 may request for CR2 and T2 may request for CR1 later which may lead to the deadlock.

Reference :

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 :