edited by
21,762 views
48 votes
48 votes

Let $m[0]\ldots m[4]$ be mutexes (binary semaphores) and $P[0]\ldots P[4]$ be processes. 
Suppose each process $P[i]$ executes the following:

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

This could cause

  1. Thrashing
  2. Deadlock
  3. Starvation, but not deadlock
  4. None of the above
edited by

7 Answers

5 votes
5 votes
B) Deadlock

in case if every process execute their first instruction and pre-empt then every process will be waiting for every other process, hence cycle.
4 votes
4 votes

( Above code is converted into simple 

'wait()' and 'signal()' operations)
 
$Deadlock$   is the correct choice.
 
 
–6 votes
–6 votes
I think there will be no deadlock as there is no circular wait.

For P[3] it will be m[3] and m[0] and for p[4] it will be m[4] and m[1]. There is no circular wait.

But there might be starvation because of higher priority processes.

So, answer is C.

Anyone correct me if I am wrong.
Answer:

Related questions