-
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 :
-
- x = 1, y = 2
- x = 2, y = l
- x = 2, y = 2
- x = l, y = 1
- x = 1, y = 2
Correct Option: C
In an multithreaded program P executes with X number of threads and Y number of locks for ensuring mutual exclustion while operating on shared memory location. Now consider each option.
(a) X = 1, Y = 2.
If there is one thread and two locks then there is not situation of deadlock.
(b) X = 2, Y = 1.
Similarly if there is only 1 lock and 2 thread, then there will be no deadlock situation.
(c) X = 2, Y = 2
If there is 2 thread and 2 locks then the Deadlock situation can arise because both threads can holds one lock and can wait for release of another lock, which arises deadlock.
(d) X = 1, Y = 1
If there is one thread and one locks, then one thread can hold one lock, then there will be no deadlock situation.
So, option (c) is correct.