Critical-Section

Question 1

Consider the following scheme for implementing a critical section in a situation with three processes and Pj and Pk.

     Pi;
     repeat
            flag [i]:=true;
     while flag [j] or flag [k] do
            case turn of
            j : if flag [j] then
            begin
            flag [i]:=false;
            while turn ≠ i do skip;
            flag [i] : true
            end;
     k : if flag [k] then
            begin
            flag [i]:=false,
            while turn ≠ i do skip;
            flag [i]:=true
            end
     end
     critical section
     if turn = i then turn:=j;
     flag [i]:=false
     non-critical section
     until false; 

(a) Does the scheme ensure mutual exclusion in the critical section? Briefly explain.
(b) Is there a situation in which a waiting process can never enter the critical section? If so, explain and suggest modifications to the code to solve this problem.

A
Theory Explanation.
There is 1 question to complete.

Access quiz wise question and answers by becoming as a solutions adda PRO SUBSCRIBER with Ad-Free content

Register Now

If you have registered and made your payment please contact solutionsadda.in@gmail.com to get access