 in computer science, priority inversion is a problematic scenario in scheduling in which a high priority task is indirectly preempted by a medium priority task effectively "inverting" the relative priorities of the two tasks. this violates the priority model that high priority tasks can only be prevented from running by higher priority tasks and briefly by low priority tasks which will quickly complete their use of a resource shared by the high and low priority tasks. ==example of a priority inversion== consider two tasks h and l, of high and low priority respectively, either of which can acquire exclusive use of a shared resource r. if h attempts to acquire r after l has acquired it, then h becomes unrunnable (blocked) until l relinquishes the resource. sharing an exclusive-use resource (r in this example) in a well-designed system typically involves l relinquishing r promptly so that h (a higher priority task) does not stay blocked for excessive periods of time. despite good design, however, it is possible that a third task m of medium priority (p(l) < p(m) < p(h), where p(x) represents the priority for task x) becomes runnable during l's use of r. at this point, m being higher in priority than l preempts l, causing l to stay unable to relinquish r, in turn causing h -- the highest priority process -- to be unable to run. this is the surprising result named priority inversion where a higher priority task is preempted by a lower priority one. ==consequences== in some cases, priority inversion can occur without causing immediate harmâthe delayed execution of the high priority task goes unnoticed, and eventually the low priority task releases the shared resource. however, there are also many situations in which priority inversion can cause serious problems. if the high priority task is left starved of the resources, it might lead to a system malfunction or the triggering of pre-defined corrective measures, such as a watch dog timer resetting the entire system. the trouble experienced by the mars lander "mars pathfinder"what really happened on mars by glenn reeves of the jpl pathfinder teamexplanation of priority inversion problem experienced by mars pathfinder is a classic example of problems caused by priority inversion in realtime systems. priority inversion can also reduce the perceived performance of the system. low priority tasks usually have a low priority because it is not important for them to finish promptly (for example, they might be a batch job or another non-interactive activity). similarly, a high priority task has a high priority because it is more likely to be subject t
Concurrency_control Embedded_systems Software_bugs