What is priority inversion?

前端 未结 11 2025
北恋
北恋 2020-12-22 15:05

I\'ve heard the phrase \'priority inversion\' in reference to development of operating systems.

What exactly is priority inversion?

What is the problem it\'s

11条回答
  •  既然无缘
    2020-12-22 16:01

    Let me make it very simple and clear. (This answer is based on the answers above but presented in crisp way).

    Say there is a resource R and 3 processes. L, M, H. where p(L) < p(M) < p(H) (where p(X) is priority of X).

    Say

    • L starts executing first and catch holds on R. (exclusive access to R)
    • H comes later and also want exclusive access to R and since L is holding it, H has to wait.
    • M comes after H and it doesn't need R. And since M has got everything it wants to execute it forces L to leave as it has high priority compared to L. But H cannot do this as it has a resource locked by L which it needs for execution.

    Now making the problem more clear, actually the M should wait for H to complete as p(H) > p(M) which didn't happen and this itself is the problem. If many processes such as M come along and don't allow the L to execute and release the lock H will never execute. Which can be hazardous in time critical applications

    And for solutions refer the above answers :)

提交回复
热议问题