Wednesday, 25 October 2017

Net 28

CBSE NET January 2017 PAPER II

OPERATING SYSTEM

Q. There are three processes P1, P2 and P3 sharing a semaphore for synchronising a variable. Initial value of semaphore is one. Assume that negative value of semaphore tells us how many processes are waiting in queue. Processes access the semaphore in following order:
(a) P2 needs to access
(b) P1 needs to access
(c) P3 needs to access
(d) P2 exits critical section
(e) Pi exits critical section
The final value of semaphore will be:

(A) 0
(B) 1
(C) -1
(D) -2

Ans :- (A)

Explanation:-

Given,Initial value of semaphore S = 1.
(a) When P2 needs to  access, S=0
(b) Now P1 needs to access, S=-1, which says 1 process P1 on wait, because P2 in section.
(c)  Now P3 needs to access, S= -2, which says 2 processes P1 and P2 on wait, because in P2 in section.
(d) Now P2 exits critical section, so P1 enter,S= -1, because only P2 on wait.
(e) Now P1 exits critical section, so P2 enter,S= 0, because no process on wait.

So, correct answer is A.

Related topics

Professor Jayesh video tutorial

Please use contact page in this website if you find anything incorrect or you want to share more information about the topic discussed above.