<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
deadlock	B-Operating_System
prevention	I-Operating_System
algorithms	I-Operating_System
are	O
used	O
in	O
concurrent	B-Architecture
programming	I-Architecture
when	O
multiple	O
processes	O
must	O
acquire	O
more	O
than	O
one	O
shared	B-General_Concept
resource	I-General_Concept
.	O
</s>
<s>
This	O
situation	O
is	O
called	O
a	O
deadlock	B-Operating_System
.	O
</s>
<s>
A	O
deadlock	B-Operating_System
prevention	O
algorithm	O
organizes	O
resource	O
usage	O
by	O
each	O
process	O
to	O
ensure	O
that	O
at	O
least	O
one	O
process	O
is	O
always	O
able	O
to	O
get	O
all	O
the	O
resources	O
it	O
needs	O
.	O
</s>
<s>
One	O
such	O
example	O
of	O
deadlock	B-Operating_System
algorithm	O
is	O
Banker	B-Operating_System
's	I-Operating_System
algorithm	I-Operating_System
.	O
</s>
<s>
+	O
Deadlock	B-Operating_System
prevention	O
techniques	O
and	O
algorithms	O
Name	O
Coffman	O
conditions	O
Description	O
Banker	B-Operating_System
's	I-Operating_System
algorithm	I-Operating_System
Mutual	O
exclusion	O
The	O
Banker	B-Operating_System
's	I-Operating_System
algorithm	I-Operating_System
is	O
a	O
resource	B-Algorithm
allocation	I-Algorithm
and	O
deadlock	B-Operating_System
avoidance	O
algorithm	O
developed	O
by	O
Edsger	O
Dijkstra	O
.	O
</s>
<s>
Distributed	O
deadlocks	B-Operating_System
can	O
occur	O
in	O
distributed	B-Architecture
systems	I-Architecture
when	O
distributed	B-General_Concept
transactions	I-General_Concept
or	O
concurrency	B-Operating_System
control	I-Operating_System
is	O
being	O
used	O
.	O
</s>
<s>
Distributed	O
deadlocks	B-Operating_System
can	O
be	O
detected	O
either	O
by	O
constructing	O
a	O
global	O
wait-for	B-Operating_System
graph	I-Operating_System
,	O
from	O
local	O
wait-for	B-Operating_System
graphs	I-Operating_System
at	O
a	O
deadlock	B-Operating_System
detector	O
or	O
by	O
a	O
distributed	B-Operating_System
algorithm	I-Operating_System
like	O
edge	O
chasing	O
.	O
</s>
<s>
Phantom	O
deadlocks	B-Operating_System
are	O
deadlocks	B-Operating_System
that	O
are	O
detected	O
in	O
a	O
distributed	B-Architecture
system	I-Architecture
due	O
to	O
system	O
internal	O
delays	O
but	O
no	O
longer	O
actually	O
exist	O
at	O
the	O
time	O
of	O
detection	O
.	O
</s>
<s>
There	O
are	O
many	O
different	O
ways	O
to	O
increase	O
parallelism	O
where	O
recursive	O
locks	O
would	O
otherwise	O
cause	O
deadlocks	B-Operating_System
.	O
</s>
<s>
Some	O
examples	O
include	O
:	O
lock	O
hierarchies	O
,	O
lock	O
reference-counting	O
and	O
preemption	O
(	O
either	O
using	O
versioning	O
or	O
allowing	O
data	O
corruption	O
when	O
preemption	O
occurs	O
)	O
;	O
Wait-For-Graph	O
(	O
WFG	O
)	O
algorithms	O
,	O
which	O
track	O
all	O
cycles	O
that	O
cause	O
deadlocks	B-Operating_System
(	O
including	O
temporary	O
deadlocks	B-Operating_System
)	O
;	O
and	O
heuristics	O
algorithms	O
which	O
do	O
n't	O
necessarily	O
increase	O
parallelism	O
in	O
100%	O
of	O
the	O
places	O
that	O
deadlocks	B-Operating_System
are	O
possible	O
,	O
but	O
instead	O
compromise	O
by	O
solving	O
them	O
in	O
enough	O
places	O
that	O
performance/overhead	O
vs	O
parallelism	O
is	O
acceptable	O
.	O
</s>
<s>
For	O
non-recursive	O
locks	O
,	O
a	O
lock	O
may	O
be	O
entered	O
only	O
once	O
(	O
where	O
a	O
single	O
thread	O
entering	O
twice	O
without	O
unlocking	O
will	O
cause	O
a	O
deadlock	B-Operating_System
,	O
or	O
throw	O
an	O
exception	O
to	O
enforce	O
circular	B-Operating_System
wait	I-Operating_System
prevention	O
)	O
.	O
</s>
<s>
So	O
the	O
issue	O
with	O
the	O
first	O
one	O
is	O
that	O
it	O
does	O
no	O
deadlock	B-Operating_System
prevention	O
at	O
all	O
.	O
</s>
<s>
The	O
second	O
does	O
not	O
do	O
distributed	O
deadlock	B-Operating_System
prevention	O
.	O
</s>
<s>
But	O
the	O
second	O
one	O
is	O
redefined	O
to	O
prevent	O
a	O
deadlock	B-Operating_System
scenario	O
the	O
first	O
one	O
does	O
not	O
address	O
.	O
</s>
<s>
If	O
a	O
deadlock	B-Operating_System
scenario	O
exists	O
,	O
set	O
a	O
new	O
super-thread	O
and	O
follow	O
that	O
logic	O
.	O
</s>
<s>
But	O
if	O
it	O
is	O
used	O
with	O
other	O
locking	O
mechanisms	O
,	O
a	O
lock	O
that	O
is	O
started	O
never	O
unlocks	O
(	O
exception	O
thrown	O
jumping	O
out	O
without	O
unlocking	O
,	O
looping	O
indefinitely	O
within	O
a	O
lock	O
,	O
or	O
coding	O
error	O
forgetting	O
to	O
call	O
unlock	O
)	O
,	O
deadlocking	B-Operating_System
is	O
very	O
possible	O
.	O
</s>
<s>
Another	O
issue	O
is	O
it	O
does	O
not	O
address	O
the	O
temporary	O
deadlocking	B-Operating_System
issue	O
(	O
not	O
really	O
a	O
deadlock	B-Operating_System
,	O
but	O
a	O
performance	O
killer	O
)	O
,	O
where	O
two	O
or	O
more	O
threads	O
lock	O
on	O
each	O
other	O
while	O
another	O
unrelated	O
thread	O
is	O
running	O
.	O
</s>
<s>
These	O
temporary	O
deadlocks	B-Operating_System
could	O
have	O
a	O
thread	O
running	O
exclusively	O
within	O
them	O
,	O
increasing	O
parallelism	O
.	O
</s>
<s>
But	O
because	O
of	O
how	O
the	O
distributed	O
deadlock	B-Operating_System
detection	O
works	O
for	O
all	O
locks	O
,	O
and	O
not	O
subsets	O
therein	O
,	O
the	O
unrelated	O
running	O
thread	O
must	O
complete	O
before	O
performing	O
the	O
super-thread	O
logic	O
to	O
remove	O
the	O
temporary	O
deadlock	B-Operating_System
.	O
</s>
<s>
If	O
another	O
unrelated	O
running	O
thread	O
begins	O
before	O
the	O
first	O
unrelated	O
thread	O
exits	O
,	O
another	O
duration	O
of	O
temporary	O
deadlocking	B-Operating_System
will	O
occur	O
.	O
</s>
<s>
If	O
this	O
happens	O
continuously	O
(	O
extremely	O
rare	O
)	O
,	O
the	O
temporary	O
deadlock	B-Operating_System
can	O
be	O
extended	O
until	O
right	O
before	O
the	O
program	O
exits	O
,	O
when	O
the	O
other	O
unrelated	O
threads	O
are	O
guaranteed	O
to	O
finish	O
(	O
because	O
of	O
the	O
guarantee	O
that	O
one	O
thread	O
will	O
always	O
run	O
to	O
completion	O
)	O
.	O
</s>
<s>
This	O
can	O
be	O
further	O
expanded	O
to	O
involve	O
additional	O
logic	O
to	O
increase	O
parallelism	O
where	O
temporary	O
deadlocks	B-Operating_System
might	O
otherwise	O
occur	O
.	O
</s>
<s>
A	O
couple	O
of	O
examples	O
include	O
:	O
expanding	O
distributed	O
super-thread	O
locking	O
mechanism	O
to	O
consider	O
each	O
subset	O
of	O
existing	O
locks	O
;	O
Wait-For-Graph	O
(	O
WFG	O
)	O
algorithms	O
,	O
which	O
track	O
all	O
cycles	O
that	O
cause	O
deadlocks	B-Operating_System
(	O
including	O
temporary	O
deadlocks	B-Operating_System
)	O
;	O
and	O
heuristics	O
algorithms	O
which	O
do	O
n't	O
necessarily	O
increase	O
parallelism	O
in	O
100%	O
of	O
the	O
places	O
that	O
temporary	O
deadlocks	B-Operating_System
are	O
possible	O
,	O
but	O
instead	O
compromise	O
by	O
solving	O
them	O
in	O
enough	O
places	O
that	O
performance/overhead	O
vs	O
parallelism	O
is	O
acceptable	O
(	O
e.g.	O
</s>
<s>
for	O
each	O
processor	O
available	O
,	O
work	O
towards	O
finding	O
deadlock	B-Operating_System
cycles	O
less	O
than	O
the	O
number	O
of	O
processors	O
+	O
1	O
deep	O
)	O
.	O
</s>
