3,256 views
3 votes
3 votes

Mutual Exclusion is important for deadlock to happen. Is this statement necessarily true always ?

2 Answers

Best answer
5 votes
5 votes

It  is not necessary that for a deadlock to happen , mutual exclusion must be there..It may happen that a solution can suffer from mutual exclusion as well as deadlock.

Consider the following code-snippet as a counter example :

Let we have P[0] , P[1] .. , P[4] be the processes and M[0] ,......M[4] be the mutex locks(binary semaphore) initialised to 1 and process P[i] executes : 

wait(m[i]) ;

wait(m[(i+1) mod 4];

critical section

signal(m[i]) ; 

signal(m[(i+1) mod 4];

Here say P[0] and P[1] can enter simultaneously thereby violating mutual exclusion property.

For deadlock to happen , for each P[i] we pre empt them after executing the first statement only.So we will have circular wait condition when each of these come to execute the second wait() statement and no P[i] can enter into critical section thereby causing deadlock.

Hence the given assertion should be false.

selected by
3 votes
3 votes

A deadlock situation on a resource can arise if and only if all of the following conditions hold simultaneously in a system:[

1.Mutual Exclusion

2.Hold and Wait

3.No Preemption

4.circular  wait

This is what Wikipedia says and I Agree..notice the word "CAN" which means if all four conditions are there that implies deadlock CAN occur and vice versa is also true

 

Wikipedia also says

While these conditions are sufficient to produce a deadlock on single-instance resource systems, they only indicate the possibility of deadlock on systems having multiple instances of resources.

that is why we uses Banker's algo to find if system is in safe state or not, because these four condition only tell us about the posibility of deadlock

CONCLUSION

If DEADLOCK is there this implies all four conditions are true

if All four conditions are true there is a possibility that deadlock might occur

 

Related questions