How single thread can deadlock with a non-reentrant lock (Option D), an example just to give idea how it is possible:
Let the thread execute a function \( t() \) which recursively calls itself.
Since the first statement inside \( t() \) is \( \text{acquire}(L) \), the recursive call
attempts to acquire the same lock again while the same thread already holds it.
Because the lock is non-reentrant, this second acquire cannot succeed and the thread blocks,
causing a self-deadlock.
int i = 0; // thread variable
lock L; // NON-reentrant lock
void t() {
acquire(L); // first acquire
if (i == 0) {
i = 1;
t(); // recursive call → tries acquire(L) again
}
release(L);
}
(Note: Example is minimal and illustrative; real implementations may differ)
Execution:
1. First call to t(): acquire(L) succeeds because the lock is free.
2. Since i = 0, the function makes a recursive call to t().
3. The recursive call again begins with its first statement: acquire(L).
4. But the same thread already holds L, and since L is a non-reentrant lock, this second acquire blocks.
5. The thread is now waiting for a lock that it itself holds, so it can never reach release(L) → this results in a self-deadlock.
If L were reentrant, the second acquire(L) would simply be treated as the same thread re-entering the lock, the recursion count would increase, and the program would continue normally with no blocking and no deadlock.