GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 32
Consider the following statements:
- I. Mutual-exclusion, hold and wait, no-preemption, circular-wait, are required condition for deadlock.
- II. A cyclic dependency always lead to deadlock.
- III. Deadlock avoidance ensures the system is always in a safe state by not granting requests that may move the system to an unsafe state .
Which of the following option is correct?
(A) Statement I, II are true and statement III is false.
(B) Statement I, III are true and statement II is false.
(C) Statement II, III are true and statement I is false.
(D) All I, II, and III are true.
Explanation: I. Four conditions required for deadlock:
- Mutual-exclusion: a resource can be possessed by only one thread.
- Hold and wait: A thread can hold a resource such as a lock while waiting for another.
- No-preemption: The resource cannot be taken away from the thread.
- Circular-wait: Two or more threads form a circular chain where each thread waits for a resource that the next thread in the chain holds.
II. No. If multiple equivalent resources exist, then a cycle could exist that is not a deadlock. The reason is that some thread that is not part of the cycle could release a resource needed by a thread in the cycle, thereby breaking the cycle.
III. Deadlock avoidance ensures the system is always in a safe state by not granting requests that may move the system to an unsafe state. A is considered safe if it is possible for all processes to finish executing (i.e. a sequence exists such that each process can be given all its required resources, run to completion, and return resources allocated, thus allowing another process to do the same, etc until all process complete). Deadlock avoidance requires the system to keep track of the resources such that it knows the allocated, available, and remaining resource needs.
So, option (B) is correct.
Quiz of this Question