If you want to make money online : Register now

[Solved]: Priority inversion in Hoare and Mesa monitors

, , No Comments
Problem Detail: 

I understand the difference between Hoare and Mesa monitors. However I don't understand why priority inversion (when a lower priority process gets done before a higher priority process) is possible in the Hoare type but not possible in the Mesa type. Can someone explain this?

Asked By : FutureTrillionaire

Answered By : Wandering Logic

Unless you are careful priority inversion is possible in either Hoare type or Mesa type monitors. This is because monitors implement a form of mutual exclusion (only one process can be "in" the monitor at a time), and mutual exclusion and priorities don't mix well. Boosting the priority of the thread in the monitor, mitigates (but does not completely solve) the problem. Priority boosting is typically done either with a priority ceiling, or priority inheritance, or both.

Hoare type condition variables introduce an additional priority inversion problem, though. In Hoare type condition variables a low-priority thread may WAIT on the condition variable (thus giving up the monitor lock), then a high-priority thread could run, make the condition true and SIGNAL the condition variable. In a Hoare type condition variable, the high priority thread immediately loses the monitor lock and gives it to the lower-priority thread.

In a Mesa type condition variable this particular priority inversion won't happen. The low-priority thread WAITs on the condition variable, giving up the monitor lock. Then a high-priority thread runs, makes the condition true and NOTIFYs the condition variable. The high-priority thread does not give up the monitor lock, and keeps running.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/47754

3.2K people like this

 Download Related Notes/Documents

0 comments:

Post a Comment

Let us know your responses and feedback