in Operating System
291 views
3 votes
3 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 
in Operating System
by
291 views

2 Comments

Why not d?
0
0
0
0

Please log in or register to answer this question.

Answer:

Related questions