edited by
24,926 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
edited by

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

13.3k
views
8 answers
61 votes
Ishrat Jahan asked Nov 3, 2014
13,284 views
Two concurrent processes $P1$ and $P2$ use four shared resources $R1, R2, R3$ and $R4$ ... $2$3$4$
14.3k
views
5 answers
69 votes
Ishrat Jahan asked Nov 3, 2014
14,258 views
A disk has $8$ equidistant tracks. The diameters of the innermost and outermost tracks are $1$ cm and $8$ cm respectively. The innermost track has a storage capacity of $10$ MB.If ... $10 \ ms$9.5 \ ms$20 \ ms$
12.2k
views
3 answers
45 votes
Ishrat Jahan asked Nov 3, 2014
12,241 views
A disk has $8$ equidistant tracks. The diameters of the innermost and outermost tracks are $1$ cm and $8$ cm respectively. The innermost track has a storage capacity of $10$ MB.What ... $360 \ \text{MB}$; II. $80 \ \text{MB}$
6.6k
views
1 answers
30 votes
Ishrat Jahan asked Nov 3, 2014
6,559 views
In a computer system, four files of size $11050$ bytes, $4990$ bytes, $5170$ bytes and $12640$ bytes need to be stored. For storing these files on disk, we ... bytes$35800$ and $35400$ bytes$35600$ and $35400$ bytes$35400$ and $35600$ bytes