Algoritmo de exclusion mutua de Peterson para 2 procesos
--------------------------------------------------------
var flag: array[0..1] of boolean;(*inicialmente FALSE*)
    turn: 0..1; (*valor 0 ó 1, inicialmente*)

       Pi
---------------------------
repeat
  flag[i]:= true;
  turn:= i;
  while (flag[j]=true and turn=i) do
    nothing enddo;
  < seccion critica>;
  flag[i]:= false;
until false;