<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
priority	B-Operating_System
inversion	I-Operating_System
is	O
a	O
scenario	O
in	O
scheduling	O
in	O
which	O
a	O
high	O
priority	O
task	B-General_Concept
is	O
indirectly	O
superseded	O
by	O
a	O
lower	O
priority	O
task	B-General_Concept
effectively	O
inverting	O
the	O
assigned	O
priorities	O
of	O
the	O
tasks	O
.	O
</s>
<s>
Inversion	O
occurs	O
when	O
there	O
is	O
a	O
resource	B-General_Concept
contention	I-General_Concept
with	O
a	O
low-priority	O
task	B-General_Concept
that	O
is	O
then	O
preempted	B-Operating_System
by	O
a	O
medium-priority	O
task	B-General_Concept
.	O
</s>
<s>
Sharing	O
an	O
exclusive-use	O
resource	O
(	O
R	O
in	O
this	O
case	O
)	O
in	O
a	O
well-designed	O
system	O
typically	O
involves	O
L	O
relinquishing	O
R	O
promptly	O
so	O
that	O
H	O
(	O
a	O
higher	O
priority	O
task	B-General_Concept
)	O
does	O
not	O
stay	O
blocked	O
for	O
excessive	O
periods	O
of	O
time	O
.	O
</s>
<s>
Despite	O
good	O
design	O
,	O
however	O
,	O
it	O
is	O
possible	O
that	O
a	O
third	O
task	B-General_Concept
M	O
of	O
medium	O
priority	O
becomes	O
runnable	O
during	O
L	O
's	O
use	O
of	O
R	O
.	O
At	O
this	O
point	O
,	O
M	O
being	O
higher	O
in	O
priority	O
than	O
L	O
,	O
preempts	O
L	O
(	O
since	O
M	O
does	O
not	O
depend	O
on	O
R	O
)	O
,	O
causing	O
L	O
to	O
not	O
be	O
able	O
to	O
relinquish	O
R	O
promptly	O
,	O
in	O
turn	O
causing	O
H	O
—	O
the	O
highest	O
priority	O
process	O
—	O
to	O
be	O
unable	O
to	O
run	O
(	O
that	O
is	O
,	O
H	O
suffers	O
unexpected	O
blockage	O
indirectly	O
caused	O
by	O
lower	O
priority	O
tasks	O
like	O
M	O
)	O
.	O
</s>
<s>
In	O
some	O
cases	O
,	O
priority	B-Operating_System
inversion	I-Operating_System
can	O
occur	O
without	O
causing	O
immediate	O
harm	O
—	O
the	O
delayed	O
execution	O
of	O
the	O
high-priority	O
task	B-General_Concept
goes	O
unnoticed	O
,	O
and	O
eventually	O
the	O
low-priority	O
task	B-General_Concept
releases	O
the	O
shared	O
resource	O
.	O
</s>
<s>
However	O
,	O
there	O
are	O
also	O
many	O
situations	O
in	O
which	O
priority	B-Operating_System
inversion	I-Operating_System
can	O
cause	O
serious	O
problems	O
.	O
</s>
<s>
If	O
the	O
high-priority	O
task	B-General_Concept
is	O
left	O
starved	B-Operating_System
of	O
the	O
resources	O
,	O
it	O
might	O
lead	O
to	O
a	O
system	O
malfunction	O
or	O
the	O
triggering	O
of	O
pre-defined	O
corrective	O
measures	O
,	O
such	O
as	O
a	O
watchdog	B-Application
timer	I-Application
resetting	O
the	O
entire	O
system	O
.	O
</s>
<s>
The	O
trouble	O
experienced	O
by	O
the	O
Mars	O
Pathfinder	O
lander	O
in	O
1997	O
is	O
a	O
classic	O
example	O
of	O
problems	O
caused	O
by	O
priority	B-Operating_System
inversion	I-Operating_System
in	O
realtime	B-General_Concept
systems	I-General_Concept
.	O
</s>
<s>
Priority	B-Operating_System
inversion	I-Operating_System
can	O
also	O
reduce	O
the	O
perceived	B-General_Concept
performance	I-General_Concept
of	O
the	O
system	O
.	O
</s>
<s>
Low-priority	O
tasks	O
usually	O
have	O
a	O
low	O
priority	O
because	O
it	O
is	O
not	O
important	O
for	O
them	O
to	O
finish	O
promptly	O
(	O
for	O
example	O
,	O
they	O
might	O
be	O
a	O
batch	B-General_Concept
job	I-General_Concept
or	O
another	O
non-interactive	O
activity	O
)	O
.	O
</s>
<s>
Similarly	O
,	O
a	O
high-priority	O
task	B-General_Concept
has	O
a	O
high	O
priority	O
because	O
it	O
is	O
more	O
likely	O
to	O
be	O
subject	O
to	O
strict	O
time	O
constraints	O
—	O
it	O
may	O
be	O
providing	O
data	O
to	O
an	O
interactive	O
user	O
,	O
or	O
acting	O
subject	O
to	O
real-time	O
response	O
guarantees	O
.	O
</s>
<s>
Because	O
priority	B-Operating_System
inversion	I-Operating_System
results	O
in	O
the	O
execution	O
of	O
a	O
lower-priority	O
task	B-General_Concept
blocking	O
the	O
high-priority	O
task	B-General_Concept
,	O
it	O
can	O
lead	O
to	O
reduced	O
system	O
responsiveness	O
or	O
even	O
the	O
violation	O
of	O
response	O
time	O
guarantees	O
.	O
</s>
<s>
A	O
similar	O
problem	O
called	O
deadline	O
interchange	O
can	O
occur	O
within	O
earliest	B-Operating_System
deadline	I-Operating_System
first	I-Operating_System
scheduling	I-Operating_System
(	O
EDF	O
)	O
.	O
</s>
<s>
published	O
one	O
of	O
the	O
first	O
papers	O
to	O
point	O
out	O
the	O
priority	B-Operating_System
inversion	I-Operating_System
problem	O
.	O
</s>
<s>
When	O
disabling	O
interrupts	O
is	O
used	O
to	O
prevent	O
priority	B-Operating_System
inversion	I-Operating_System
,	O
there	O
are	O
only	O
two	O
priorities	O
:	O
preemptible	O
,	O
and	O
interrupts	O
disabled	O
.	O
</s>
<s>
If	O
only	O
a	O
particular	O
hardware	O
device	O
's	O
interrupt	O
is	O
disabled	O
,	O
priority	B-Operating_System
inversion	I-Operating_System
is	O
reintroduced	O
by	O
the	O
hardware	O
's	O
prioritization	O
of	O
interrupts	O
.	O
</s>
<s>
By	O
properly	O
choosing	O
the	O
highest	O
priority	O
of	O
any	O
interrupt	O
that	O
ever	O
entered	O
the	O
critical	O
section	O
,	O
the	O
priority	B-Operating_System
inversion	I-Operating_System
problem	O
could	O
be	O
solved	O
without	O
locking	O
out	O
all	O
of	O
the	O
interrupts	O
.	O
</s>
<s>
Ceilings	O
were	O
assigned	O
in	O
rate-monotonic	B-Operating_System
order	O
,	O
i.e.	O
</s>
<s>
This	O
scheme	O
provides	O
a	O
single	O
flag	O
in	O
shared	O
memory	O
that	O
is	O
used	O
by	O
all	O
CPUs	O
to	O
lock	O
all	O
inter-processor	O
critical	O
sections	O
with	O
a	O
busy-wait	B-Operating_System
.	O
</s>
<s>
These	O
methods	O
are	O
widely	O
used	O
in	O
simple	O
embedded	B-Architecture
systems	I-Architecture
,	O
where	O
they	O
are	O
prized	O
for	O
their	O
reliability	O
,	O
simplicity	O
and	O
low	O
resource	O
use	O
.	O
</s>
<s>
With	O
priority	B-Operating_System
ceiling	I-Operating_System
protocol	I-Operating_System
,	O
the	O
shared	O
mutex	B-Operating_System
process	O
(	O
that	O
runs	O
the	O
operating	O
system	O
code	O
)	O
has	O
a	O
characteristic	O
(	O
high	O
)	O
priority	O
of	O
its	O
own	O
,	O
which	O
is	O
assigned	O
to	O
the	O
task	B-General_Concept
of	O
locking	O
the	O
mutex	B-Operating_System
.	O
</s>
<s>
This	O
works	O
well	O
,	O
provided	O
the	O
other	O
high-priority	O
task(s )	O
that	O
tries	O
to	O
access	O
the	O
mutex	B-Operating_System
does	O
not	O
have	O
a	O
priority	O
higher	O
than	O
the	O
ceiling	O
priority	O
.	O
</s>
<s>
Under	O
the	O
policy	O
of	O
priority	B-Operating_System
inheritance	I-Operating_System
,	O
whenever	O
a	O
high-priority	O
task	B-General_Concept
has	O
to	O
wait	O
for	O
some	O
resource	O
shared	O
with	O
an	O
executing	O
low-priority	O
task	B-General_Concept
,	O
the	O
low-priority	O
task	B-General_Concept
is	O
temporarily	O
assigned	O
the	O
priority	O
of	O
the	O
highest	O
waiting	O
priority	O
task	B-General_Concept
for	O
the	O
duration	O
of	O
its	O
own	O
use	O
of	O
the	O
shared	O
resource	O
,	O
thus	O
keeping	O
medium	O
priority	O
tasks	O
from	O
pre-empting	O
the	O
(	O
originally	O
)	O
low	O
priority	O
task	B-General_Concept
,	O
and	O
thereby	O
affecting	O
the	O
waiting	O
high	O
priority	O
task	B-General_Concept
as	O
well	O
.	O
</s>
<s>
Once	O
the	O
resource	O
is	O
released	O
,	O
the	O
low-priority	O
task	B-General_Concept
continues	O
at	O
its	O
original	O
priority	O
level	O
.	O
</s>
<s>
Ready	O
tasks	O
holding	O
locks	O
are	O
randomly	B-Operating_System
boosted	I-Operating_System
in	O
priority	O
until	O
they	O
exit	O
the	O
critical	O
section	O
.	O
</s>
<s>
This	O
solution	O
is	O
used	O
in	O
Microsoft	B-Application
Windows	I-Application
.	O
</s>
<s>
Because	O
priority	B-Operating_System
inversion	I-Operating_System
involves	O
a	O
low-priority	O
task	B-General_Concept
blocking	O
a	O
high-priority	O
task	B-General_Concept
,	O
one	O
way	O
to	O
avoid	O
priority	B-Operating_System
inversion	I-Operating_System
is	O
to	O
avoid	O
blocking	O
,	O
for	O
example	O
by	O
using	O
non-blocking	B-Operating_System
algorithms	I-Operating_System
such	O
as	O
read-copy-update	B-Operating_System
.	O
</s>
