Open In App

Difference between Priority Inversion and Priority Inheritance

Last Updated : 02 Nov, 2022
Like Article

Both of these concepts come under Priority scheduling in Operating System. But are they the same?

In one line, Priority Inversion is a problem while Priority Inheritance is a solution. Priority Inversion means that the priority of tasks gets inverted and Priority Inheritance means that the priority of tasks gets inherited. Both of these phenomena happen in priority scheduling. Basically, in Priority Inversion, the higher priority task (H) ends up waiting for the middle priority task (M) when H is sharing a critical section with the lower priority task (L) and L is already in the critical section. Effectively, H waiting for M results in inverted priority i.e. Priority Inversion. One of the solutions to this problem is Priority Inheritance. In Priority Inheritance, when L is in the critical section, L inherits the priority of H at the time when H starts pending for the critical section. By doing so, M doesn’t interrupt L and H doesn’t wait for M to finish. Please note that inheriting of priority is done temporarily i.e. L goes back to its old priority when L comes out of the critical section.

Let us see the differences in a tabular form:


Priority Inversion

Priority Inheritance

1. In priority inversion, a higher-priority process is preempted by a lower-priority process. It is a method that is used to eliminate the problems of Priority inversion.
2. It is the inversion of the priorities of the two processes With the help of this, a process scheduling algorithm increases the priority of a process, to the maximum priority of any other process waiting for any resource.
3. It can cause a system to malfunction in our system. Priority inheritance can lead to poorer worst-case behavior when there are nested locks.
4. Priority inversions can lead to the implementation of corrective measures. Priority inheritance can be implemented such that there is no penalty when the locks do not contend,

To deal with the problem of priority inversion we can have several techniques such as 

Priority ceiling, Random boosting, etc.

It is the basic technique at the application level for managing priority inversion.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads