470 views
4 votes
4 votes

Consider Peterson's algorithm for Mutual Exclusion between two concurrent processes $w$ and $f$. The program executed by the processeses are shown below:

Process w Process f
repeat 
    flag[w]=true; 
    turn=f; 
    while(P) do 
        no-operation; 
    Enter critical section,  
    perform actions, 
    exit critical section 
    flag[w]=false; 
    perform non critical section actions 
until false;
repeat 
    flag[f]=true; 
    turn=w; 
    while(Q) do 
        no-operation; 
    Enter critical section,  
    perform actions, 
    exit critical section 
    flag[f]=false; 
    perform non critical section actions 
until false;

For the program to guarantee Mutual Exclusion the predicate $P$ in the while loop should be 

  1. flag[f]=true and turn = w 
  2. flag[f]=true and turn=f 
  3. flag[w]=true and turn=f                  
  4. flag[w]=true and turn=w 

Please log in or register to answer this question.

Answer:

Related questions

1 votes
1 votes
2 answers
2