Software Solution 3 (Peterson’s)
Only two processes.
Local process is i, other is j.
Mutual exclusion - good.
Progress - good.
Bounded time - good.
Shared turn: (0..1)=0;
Shared flag: array [0..1] of boolean=[false, false];
.
Repeat
flag[ i ] := true; turn := j;
while (flag[ j ] and turn=j) do no-op;
critical section
flag[ i ] := false;
remainder section
Forever
Previous slide
Next slide
Back to first slide
View graphic version