edited by
4,248 views
3 3 votes

Consider program for P1  and P2:

Here, m and n are binary semaphore variables whose values are initially initialized to 1. x and y are shared resources whose values are initialized to 0.
Which of the following holds by above processes?

A :- Deadlock and no mutual exclusion

B :-Deadlock and race condition

C :-No deadlocks and no race condition

D:- Race condition and no deadlock

3 Answers

1 1 vote

P1()
1.wait(m)
2.x++
context switch

P2()
1.wait(n)
2.y++
3.wait(m) // waiting for m to became 1
context switch

P1() // arraive again
3.wait(n)// waitning for n to become 1

1.conclusion – it create deadlock 
2.conclusion – there is mutual exclusion

 

ANS – option B

 

0 0 votes
P1 will execute wait(m) & P2 will execute wait(n) so both m & n will become 0. So when P1 will execute wait(n) & P2 will execute wait(m). They both will go to deadlock. Here, no mutual exclusion took place.
0 0 votes
The answer should be Deadlock and no race condition. The given options do not match the answer.

There exists a deadlock scenario namely

P1 and P2 both execute, both acquire m and n respectively. Both execute their respective increment statements and then both execute the wait statements trying to acquire each others acquired semaphores which creates a deadlock scenario.

There does not exist a Race condition since there is no scenario in which both P1 and P2 can execute increments of the same variable i.e x or y at the same time.
Position:
Show:

Related questions

1 1 vote
1 1 answer
1.4k
1.4k views
SamAddy asked Jan 20, 2019
1,351 views
Will there be Mutual Exclusion & Deadlock ?
6 6 votes
1 answers 1 answer
2.5k
2.5k views
Shamim Ahmed asked Jan 13, 2019
2,529 views
Let S be a binary semaphore variable, S=0What will be the value of S when following operations are performed:-2P, 4V, 5P, 2P, 8V, 3P, 2V ?
0 0 votes
0 0 answers
1.7k
1.7k views
Harsh Mehta asked Jan 13, 2018
1,661 views
I understand the Question Correctly. i know Mutual Exclusion ,But Can Anyone explain What is MUTUAL INCLUSION, ??
1 1 vote
2 2 answers
1.5k
1.5k views
ramakrushna asked Dec 18, 2021
1,507 views
If the P() and V() semaphore operations are not executed atomically, then which of the following are always correct?Mutual exclusion satisfied Progress is not satisfiedBo...