0;
while (some condition) {
while(lock); lock =
1;critical section
lock = 0;
remainder section
}
Process B
shared int lock = 0;
while (some condition) {
while(lock); lock = 1;
critical section
lock = 0;
remainder section
}
while(lock);
lock = 1;
critical section
critical section
critical section
while(lock); while(lock); while(lock); while(lock); while(lock);
critical section
critical section
critical section
critical section
critical section
while(lock); while(lock); while(lock); while(lock); while(lock);
critical section
critical section
lock = 0;
remainder section
remainder section
while(lock);
lock = 1;
critical section
critical section
critical section
A
B
A
B
A
B