149 views
4 4 votes

Consider the following variation of Peterson’s algorithm for process $P_i$:

$\texttt{flag[i] = TRUE;}$

$\texttt{turn = i;}$

$\texttt{while(flag[j] \&\& turn == j);}$

$\texttt{Critical Section}$

$\texttt{flag[i] = FALSE;}$

Which critical-section requirement can be violated?

  1. Mutual exclusion
     
  2. Progress only
     
  3. Bounded waiting only
     
  4. None of the requirements

1 Answer

0 0 votes

For process $P_i$, the entry code is:

$\texttt{flag[i] = TRUE}$

$\texttt{turn = i}$

and it waits while:

$\texttt{while(flag[j] \&\& turn == j);}$

Suppose $P_j$ enters the critical section before $P_i$.

After leaving the critical section, $P_j$ can again execute:

$\texttt{flag[j] = TRUE}$

$\texttt{turn = j}$

Now $P_i$ again finds $\texttt{flag[j] = TRUE}$ and $\texttt{turn == j}$, so it continues waiting.

This can happen repeatedly. Hence, $P_i$ may wait indefinitely.

Therefore, bounded waiting is violated.

Mutual exclusion and progress are still satisfied.

$\boxed{\text{Answer: C}}$

• edited by
Answer:
Position:
Show:

Related questions

4 4 votes
1 1 answer
164
164 views
GO Classes asked Jul 29
164 views
Consider the following alternative entry code for process $P_i$:$\texttt{wants[i] = 1}$;$\texttt{while(wants[1 - i]);}$The shared array $\texttt{wants}$ is initially:$\te...
7 7 votes
1 1 answer
198
198 views
GO Classes asked Jul 29
198 views
Which of the following statements about Peterson’s solution are correct?Peterson’s solution uses atomic load and store operations. Peterson’s solution directly supports a...
2 2 votes
1 1 answer
121
121 views
GO Classes asked Jul 29
121 views
Two threads execute Peterson’s entry code. The following statements execute in this exact order:$T_0:$ $\texttt{flag[0] = true}$$T_0:$ $\texttt{turn = 1}$$T_1:$ $\texttt{...
2 2 votes
1 1 answer
127
127 views
GO Classes asked Jul 29
127 views
Which of the following statements are correct?Both strict alternation and Peterson’s solution use busy waiting. Both strict alternation and Peterson’s solution satisfy th...