Consider the following algorithm as a solution to the Critical Section problem.
The process shares two variables:
var flag: array [0….1] of Boolean;
turn= 0…..1;
Initially flag [0]= flag [1]= false;
turn= 0 (or) 1;
the structure of process Pi is like
repeat
flag[i] = true;
turn= j;
while (CONDITION);
CS
flag [i]= false;
………
………
until false.
What should be the Condition, so that algorithm satisfies all the three requisites i.e. ME, Progress
& BW?
(a) flag [j]= true & turn= j; (b) flag [j]= false & turn= i;
(c) flag [i]= true & turn= j; (d) flag [i]= false & turn= i;
Solution: Option (a) (need the explanation)