• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
October 31, 2022 |3.9K Views

Priority Inversion Protocol in Operating System

  Share  1 Like
Description
Discussion

In this video, we will be discussing what is priority inversion in operating system with the help of examples
Priority inversion is a problem that arises when the operating system uses priority-based scheduling. In priority-based scheduling, each process is assigned a priority such that the arrival of a higher priority process leads to the preemption of a lower priority process. 

Assume a situation where two processes H and L share the same resources in the critical section, without priority inversion, few cases are possible:

CASE 1: L is running but not in the critical section, and H needs to run. So H will preempt L. Now H starts running, and after some time, H's execution is completed. L resumes its execution. 

CASE 2: L is running inside the critical section, and H needs to run but not inside the critical section. So H will preempt L. now, H starts running, and after some time, H's execution is completed. L resumes its execution. 

CASE 3: L is running inside the critical section, and H also needs to run in the critical section. H waits for L to come out of the critical section. L comes out of the critical section, and now H enters the critical section and starts running. 

Priority Inversion CASE: Assuming a medium priority process M appears, the order of process priorities will become L<M<H. M does not share the critical section with L or H. L is running in the critical section, H needs the critical section so it waits for L to come out of the critical section. M interrupts L and starts executing, after completion M terminates and L starts running. Once L completes, H starts running, 

Running of M delayed the execution of H, although H has a higher priority than M and does not share a critical section with M, yet it waits for M to complete. In this case, priority scheduling does not follow correctly and M and H's priorities got inverted. 

Priority inversion:
https://www.geeksforgeeks.org/priority-inversion-what-the-heck/