开发者

Priority inversion

I am having problem understanding Priority Inversion

Snippet from the article:

Consider there is a task L, with low priority. This task requires resource R. Consider that L is running and it acquires resource R. Now, there is another task H, with high priority. This task also requires resource R. Consider H starts after L has acquired reso开发者_开发百科urce R. Now H has to wait until L relinquishes resource R.

Everything works as expected up to this point, but problems arise when a new task M starts with medium priority during this time. ` Since R is still in use (by L), H cannot run. Since M is the highest priority unblocked task, it will be scheduled before L. Since L has been preempted by M, L cannot relinquish R. So M will run till it is finished, then L will run - at least up to a point where it can relinquish R - and then H will run. Thus, in above scenario, a task with medium priority ran before a task with high priority, effectively giving us a priority inversion.

The question is relevant to the second part of the article. Why is that a process with H (Higher) priority cannot pre-empt a process with L (lower) priority but a process with M (medium) priority can pre-empt? i.e. If H was put to block since R was in use, why was M not blocked as well ?


Because M does not require resource R, so it is able to run while L still has it in use; H, on the other hand, cannot run until L is able to release R.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜