var flag: array[0..1] of (passive, requesting, in-cs); (*inicialmente
'passive'*)
turn: 0..1; (*valor 0 ó
1, inicialmente*)
Pi
---------------
repeat
repeat
flag[i]:= requesting;
while (i <> turn and flag[j] <> passive)
do
nothing enddo;
flag[i]:= in-cs;
until flag[j] <> in_cs;
turn:= i;
<seccion critica>;
turn:= j;
flag[j]:= passive;
until false;