GATE - 2010 | OS | The following program consists of 3 concurrent processes and 3 binary

GATE - 2010 | OS | The following program consists of 3 concurrent processes and 3 binary
Posted on 13-02-2022

GATE - 2010 [Operating System]

Question:

The following program consists of 3 concurrent processes and 3 binary semaphores.The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.

The following program consists of 3 concurrent processes and 3 binary semaphores.The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0.  

How many times will process P0 print '0'?

A

At least twice

B

Exactly twice

C

Exactly thrice

D

Exactly once

    

Solution:

Option (A) is Correct.

S0=1
S1=0
S2=0
P0 enters the critical section first,
prints (‘0’)
releases S1,S2(i.e., S1=1 & S2=1)
Now P1 & P2 both can enter critical section releases S0 & prints (‘0’)
This process continues, hence the number of zero’s printed ≥2.

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