<s>
Dekker	B-Operating_System
's	I-Operating_System
algorithm	I-Operating_System
is	O
the	O
first	O
known	O
correct	O
solution	O
to	O
the	O
mutual	B-Operating_System
exclusion	I-Operating_System
problem	O
in	O
concurrent	B-Architecture
programming	I-Architecture
where	O
processes	O
only	O
communicate	O
via	O
shared	B-Operating_System
memory	I-Operating_System
.	O
</s>
<s>
It	O
allows	O
two	O
threads	O
to	O
share	O
a	O
single-use	O
resource	O
without	O
conflict	O
,	O
using	O
only	O
shared	B-Operating_System
memory	I-Operating_System
for	O
communication	O
.	O
</s>
<s>
It	O
avoids	O
the	O
strict	O
alternation	O
of	O
a	O
naïve	O
turn-taking	O
algorithm	O
,	O
and	O
was	O
one	O
of	O
the	O
first	O
mutual	B-Operating_System
exclusion	I-Operating_System
algorithms	O
to	O
be	O
invented	O
.	O
</s>
<s>
If	O
two	O
processes	O
attempt	O
to	O
enter	O
a	O
critical	B-Operating_System
section	I-Operating_System
at	O
the	O
same	O
time	O
,	O
the	O
algorithm	O
will	O
allow	O
only	O
one	O
process	O
in	O
,	O
based	O
on	O
whose	O
it	O
is	O
.	O
</s>
<s>
If	O
one	O
process	O
is	O
already	O
in	O
the	O
critical	B-Operating_System
section	I-Operating_System
,	O
the	O
other	O
process	O
will	O
busy	B-Operating_System
wait	I-Operating_System
for	O
the	O
first	O
process	O
to	O
exit	O
.	O
</s>
<s>
This	O
is	O
done	O
by	O
the	O
use	O
of	O
two	O
flags	O
,	O
and	O
,	O
which	O
indicate	O
an	O
intention	O
to	O
enter	O
the	O
critical	B-Operating_System
section	I-Operating_System
on	O
the	O
part	O
of	O
processes	O
0	O
and	O
1	O
,	O
respectively	O
,	O
and	O
a	O
variable	O
that	O
indicates	O
who	O
has	O
priority	O
between	O
the	O
two	O
processes	O
.	O
</s>
<s>
Dekker	B-Operating_System
's	I-Operating_System
algorithm	I-Operating_System
can	O
be	O
expressed	O
in	O
pseudocode	B-Language
,	O
as	O
follows	O
.	O
</s>
<s>
Processes	O
indicate	O
an	O
intention	O
to	O
enter	O
the	O
critical	B-Operating_System
section	I-Operating_System
which	O
is	O
tested	O
by	O
the	O
outer	O
while	O
loop	O
.	O
</s>
<s>
If	O
the	O
other	O
process	O
has	O
not	O
flagged	O
intent	O
,	O
the	O
critical	B-Operating_System
section	I-Operating_System
can	O
be	O
entered	O
safely	O
irrespective	O
of	O
the	O
current	O
turn	O
.	O
</s>
<s>
Mutual	B-Operating_System
exclusion	I-Operating_System
will	O
still	O
be	O
guaranteed	O
as	O
neither	O
process	O
can	O
become	O
critical	O
before	O
setting	O
their	O
flag	O
(	O
implying	O
at	O
least	O
one	O
process	O
will	O
enter	O
the	O
while	O
loop	O
)	O
.	O
</s>
<s>
Processes	O
without	O
priority	O
will	O
withdraw	O
their	O
intention	O
to	O
enter	O
the	O
critical	B-Operating_System
section	I-Operating_System
until	O
they	O
are	O
given	O
priority	O
again	O
(	O
the	O
inner	O
while	O
loop	O
)	O
.	O
</s>
<s>
Processes	O
with	O
priority	O
will	O
break	O
from	O
the	O
while	O
loop	O
and	O
enter	O
their	O
critical	B-Operating_System
section	I-Operating_System
.	O
</s>
<s>
Dekker	B-Operating_System
's	I-Operating_System
algorithm	I-Operating_System
guarantees	O
mutual	B-Operating_System
exclusion	I-Operating_System
,	O
freedom	O
from	O
deadlock	B-Operating_System
,	O
and	O
freedom	O
from	O
starvation	B-Operating_System
.	O
</s>
<s>
There	O
is	O
freedom	O
from	O
deadlock	B-Operating_System
,	O
so	O
eventually	O
p1	O
will	O
proceed	O
to	O
its	O
critical	B-Operating_System
section	I-Operating_System
and	O
set	O
(	O
and	O
the	O
value	O
of	O
turn	O
will	O
remain	O
unchanged	O
as	O
long	O
as	O
p0	O
does	O
n't	O
progress	O
)	O
.	O
</s>
<s>
The	O
next	O
time	O
p1	O
tries	O
to	O
enter	O
its	O
critical	B-Operating_System
section	I-Operating_System
,	O
it	O
will	O
be	O
forced	O
to	O
execute	O
the	O
actions	O
in	O
its	O
loop	O
.	O
</s>
<s>
The	O
next	O
time	O
control	O
passes	O
to	O
p0	O
,	O
it	O
will	O
exit	O
the	O
loop	O
and	O
enter	O
its	O
critical	B-Operating_System
section	I-Operating_System
.	O
</s>
<s>
If	O
the	O
algorithm	O
were	O
modified	O
by	O
performing	O
the	O
actions	O
in	O
the	O
loop	O
without	O
checking	O
if	O
,	O
then	O
there	O
is	O
a	O
possibility	O
of	O
starvation	B-Operating_System
.	O
</s>
