P0 P1
non-critical section non-critical section
set v0 to true set v1 to true
repeat repeat
set v0 to false set v1 to false
set v0 to true set v1 to true
until v1 equals false until v0 equals false
critical section using r critical section using r
set v0 to false set v1 to false