336 views
0 votes
0 votes

Consider two process P, and P, which share the following variables:

boolean flag [2]; /*initially false*/

int turn;

These two processes, Pi(i = 0 or 1), Pj (j = 1 or 0) execute the following code:

do

{

flag [i] = TRUE;

while (flag [ j ])

{

if ( turn =  = j ) 

{

flag[ i ] = FALSE;

while ( turn == j );

flag[ i ] = TRUE;
}
}

//Critical Section

turn = j;

flag[ i ] = FALSE;

//remainder
}

while( TRUE );

 

The Code Satisfies

(i) Mutual Exclusion

(ii) Progress

(iii) Bounded Waiting

  1. (i) , (ii) only
  2. (ii), (iii) only
  3. (i), (iii) only
  4. (I), (ii), (iii)

 

Please log in or register to answer this question.

Related questions