in Operating System edited by
398 views
1 vote
1 vote

in Operating System edited by
398 views

1 comment

no deadlock but starvation may result
0
0

1 Answer

4 votes
4 votes
Best answer
Initial value of mutex, Q and R is 1, 1 and 1 respectively.

Suppose in computer() following instructions get execute

P(Mutex ) ----> Mutex = 0
P(Q)        -----> Q = 0
P(R)        ------> R = 0
V(Q)        -----> Q = 1

Suppose at this point Computer() get preempted by Science(), the following instructions executed in Science ()

P(Q)  -----> Q = 0
P(R)  -----> R = -1, so unsuccessful down operation, Therefore Science() cannot progress from here and wait for an V(R)

Again after sometime, Suppose Science() is preempted by Computer(), and starts to execute its remaining code...

V(mutex) ----> mutex = 1
P(Q)      -----> Q = -1, so unsuccessful down operation, Therefore Computer() cannot progress from here, and wait for V(Q)

Now the situation is Science() cannot progress and similarly Computer() is not been able to progress. And there is no possibility we are going to execute V(R) and V(Q) in near future, so Deadlock is present here, and because of this deadlock, startvation is going to happen.

Option C both deadlock and starvation is correct here.
selected by

Related questions