Junior — Middle
What is the minimum number of locks required to cause a deadlock in a system?
sobes.tech AI
Answer from AI
For a deadlock to occur in a system, at least two locks and two processes (or threads) that attempt to acquire them are necessary.
A classic example:
- Process A acquires lock 1 and tries to acquire lock 2.
- Process B acquires lock 2 and tries to acquire lock 1.
Both processes are waiting for the lock held by the other, and neither can continue — a deadlock occurs.
Thus, the minimum number of locks for a deadlock is 2.