210 views
3 3 votes

Which of the following statements are correct?

  1. In the standard reader-preference solution, the first reader executes $\texttt{wait(wrt)}$.
     
  2. In the standard reader-preference solution, the last reader executes $\texttt{signal(wrt)}$.
     
  3. Continuous arrival of readers may cause a waiting writer to starve.
     
  4. In the dining-philosophers problem with five philosophers, allowing all five philosophers to acquire their left chopsticks first prevents deadlock.

1 Answer

0 0 votes

Statement A is correct.

In the standard reader-preference solution, the first reader executes:

$\texttt{wait(wrt)}$

This prevents a writer from entering while readers are active.


Statement B is correct.

The last reader executes:

$\texttt{signal(wrt)}$

This allows a waiting writer to access the shared data.


Statement C is correct.

If readers continue arriving, the number of active readers may never become zero.

As a result, a waiting writer may remain blocked indefinitely. This is writer starvation.


Statement D is incorrect.

If all five philosophers acquire their left chopsticks first, each philosopher may hold one chopstick and wait for the other.

This creates circular waiting and may cause deadlock.

Answer:
Position:
Show:

Related questions

4 4 votes
1 1 answer
124
124 views
GO Classes asked Jul 29
124 views
Which of the following statements about disabling interrupts are correct?On a uniprocessor system, disabling interrupts can prevent the running process from being preempt...
5 5 votes
2 2 answers
284
284 views
GO Classes asked Aug 3
284 views
Which of the following techniques can prevent deadlock in the dining-philosophers problem?Allow at most four of five philosophers to attempt to acquire chopsticks simulta...
3 3 votes
2 2 answers
202
202 views
GO Classes asked Aug 3
202 views
In the standard reader-preference solution:$\texttt{mutex}$ protects $\texttt{readcount}$. $\texttt{wrt}$ controls access to the shared data.Which of the following statem...
3 3 votes
1 1 answer
150
150 views
GO Classes asked Aug 3
150 views
A shared variable $x$ is initially equal to $10$.Two threads execute the following operations exactly once without synchronization:Thread $T_1$$x = x + 1$Thread $T_2$$x =...