GATE - 2005 | OS | Given below is a program which when executed spawns two

GATE - 2005 | OS | Given below is a program which when executed spawns two
Posted on 19-02-2022

GATE - 2005 [Operating System]

Question:

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

P1

P2

repeat forever V (X) ; Compute ; P(X) ;

 repeat forever P(X) ; Compute ; V(X) ;

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?

A

Both 1 and 2 are true

B

1 is true but 2 is false

C

2 is true but 1 is false

D

Both 1 and 2 are false

   

Solution:

Option (A) is Correct.

P1 can be starves on P, then P2 loops forever.


P2 can be starves on P, then P1 loops forever.


Both statements (i) and (ii) are True.

Thank You

Download App for Free PDF Download

GovtVacancy.Net Android App: Download

government vacancy govt job sarkari naukri android application google play store https://play.google.com/store/apps/details?id=xyz.appmaker.juptmh