in Operating System edited by
23,954 views
75 votes
75 votes

Given below is a program which when executed spawns two concurrent processes :
semaphore $X : = 0 ;$
/* Process now forks into concurrent processes $P1$ & $P2$ */

$\begin{array}{|l|l|}\hline \text{$P1$}  &  \text{$P2$}  \\\hline  \text{repeat forever } & \text{repeat forever} \\ \text{$V (X) ;$ } & \text{$ P(X) ;$} \\  \text{Compute;  } & \text{Compute;}\\  \text{$P(X) ;$  } & \text{$V(X) ;$} \\\hline \end{array}$

Consider the following statements about processes $P1$ and $P2:$

  1. It is possible for process $P1$ to starve.
  2. It is possible for process $P2$ to starve.

Which of the following holds?

  1. Both (I) and (II) are true.
  2. (I) is true but (II) is false.
  3. (II) is true but (I) is false
  4. Both (I) and (II) are false
in Operating System edited by
24.0k views

4 Comments

will you please explain your line

" Since P2 can't execute signal on P1 's X. "

0
0
yes, bounded waiting will not satisfied by this code.
0
0

11 Answers

0 votes
0 votes

Option A is correct , Both the cases I have mentioned below.

0 votes
0 votes
Correct me If I am wrong..

If P1 does not execute then P2 has to starve for infinity time. If P1 enters Compute stage making x=1, then P2 can enter into Compute stage making x=0. Now P1 can not come out of the Program because it stuck in while loop due to x=0. If P2 takes infinity time to compute then P1 has to starve in the while loop infinity time. Hence both could starve.
0 votes
0 votes
They ask for any possibility not for a single case so
Both processes can starve here
p1 can starve if p1 is in c.s. and then p2 repeatedly executing.
p2 can starve if p1 repeatedly executing

So option A is correct
Answer:

Related questions