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
- (i) , (ii) only
- (ii), (iii) only
- (i), (iii) only
- (I), (ii), (iii)