Given below is solution for the critical section problem of two processes P₀…
PYQ GATE 1988
Given below is solution for the critical section problem of two processes P₀ and P₁ sharing the following variables:
var flag :array [0..1] of boolean; (initially false)
turn: 0 .. 1;
The program below is for process Pᵢ (i=0 or 1) where process Pⱼ (j=1 or 0) being the other one.
repeat
flag[i]:= true;
while turn != i
do begin
while flag[j] do skip
turn:=i;
end
critical section
flag[i]:=false;
until false
Determine of the above solution is correct. If it is incorrect, demonstrate with an example how it violates the conditions.
Sign up free to check your answer
Sign up freeLoading lesson…

