next up previous
Next: Example 2 Up: No Title Previous: Critical Section

Example 1

var enter1, enter2 = false : boolean ; 

Process P1
  loop
  {entry protocol}
  enter1 := true ; {announce intent to enter}

  while enter2
    do null end;
  {wait if other process is in CS}

  {critical section}

  enter1 := false {exit protocol}
  end
end ;

Process P2
 loop
 {entry protocol}
 enter2 := true {announce intent to enter}

 while enter1
   do null end ;
   {wait if other process is in CS}
 
 {critical section}

   enter2 := false {exit protocol}
   end
end ;



Omer F Rana
Tue Feb 11 19:19:09 GMT 1997