edited by
33,343 views
122 votes
122 votes

A multithreaded program $P$ executes with $x$ number of threads and uses $y$ number of locks for ensuring mutual exclusion while operating on shared memory locations. All locks in the program are non-reentrant, i.e., if a thread holds a lock $l$, then it cannot re-acquire lock $l$ without releasing it. If a thread is unable to acquire a lock, it blocks until the lock becomes available. The minimum value of $x$ and the minimum value of $y$ together for which execution of $P$ can result in a deadlock are:

  1. $x = 1, y = 2$
  2. $x = 2, y = 1$
  3. $x = 2, y = 2$
  4. $x = 1, y = 1$
edited by

7 Answers

0 votes
0 votes
suppose

I. p(y)

II. p(y)

cs

III. v(y)

IV. v(y)

in this case if we execute step number I then only after executing V(y) we can perform step II, else this will lead to dead lock.
0 votes
0 votes
I guess than by the same logic all binary semaphores are non-reentrant by default. so a system with single process that requires only one binary semaphore can be deadlocked. Is my interpretation right ? please  comment. thanks.
Answer:

Related questions

24 votes
24 votes
3 answers
6
48 votes
48 votes
7 answers
7
Arjun asked Feb 14, 2017
17,174 views
Threads of a process shareglobal variables but not heapheap but not global variablesneither global variables nor heapboth heap and global variables