NEOCODE

Deadlock MCQs

DEADLOCK CHARACTERIZATION

1. Which of the following is NOT a necessary condition for deadlock?

Correct Answer: e) Priority Scheduling

Explanation:
The four necessary conditions for deadlock are: Mutual Exclusion, Hold and Wait, No Preemption, and Circular Wait. Priority Scheduling is a CPU scheduling algorithm and not related to deadlock conditions.

2. A deadlock situation can arise when:

Correct Answer: b) A process is waiting for an event that will never occur

Explanation:
Deadlock occurs when processes are waiting for resources held by other processes in a circular chain, meaning each process is waiting for an event (resource release) that will never occur because the processes are blocked.

3. The four necessary conditions for deadlock are:

Correct Answer: b) Mutual Exclusion, No Preemption, Hold and Wait, Circular Wait

Explanation:
These four conditions must all hold simultaneously for a deadlock to occur: Mutual Exclusion (resources are non-shareable), Hold and Wait (process holds resources while waiting for others), No Preemption (resources cannot be forcibly taken), and Circular Wait (circular chain of waiting processes).

4. In a system with multiple instances of a resource type, deadlock occurs when:

Correct Answer: b) A circular chain of processes exists where each process holds a resource needed by the next

Explanation:
Deadlock in multi-instance resource systems occurs when there's a circular wait condition where each process in the chain holds some resources and waits for others held by the next process in the chain.

DEADLOCK PREVENTION

5. Deadlock Prevention strategies ensure that:

Correct Answer: a) At least one necessary condition for deadlock is violated

Explanation:
Deadlock prevention works by ensuring that at least one of the four necessary conditions for deadlock cannot hold, thus making deadlock impossible.

6. Which strategy prevents the "Hold and Wait" condition?

Correct Answer: b) Requiring processes to request all resources before execution

Explanation:
To prevent Hold and Wait, we can require processes to request all needed resources at once (before execution begins) and blocking the process until all are available.

7. To prevent deadlocks by violating the "No Preemption" condition, the system must:

Correct Answer: a) Allow resources to be forcibly taken from processes

Explanation:
Violating No Preemption means allowing resources to be preempted (forcibly taken) from processes when necessary to break potential deadlocks.

8. Which of the following is NOT a deadlock prevention technique?

Correct Answer: a) Resource allocation graph

Explanation:
The Resource Allocation Graph is used for deadlock detection, not prevention. Prevention techniques involve violating one of the four necessary conditions.

DEADLOCK AVOIDANCE

9. The Banker's Algorithm is used for:

Correct Answer: b) Deadlock Avoidance

Explanation:
The Banker's Algorithm is a deadlock avoidance technique that checks if granting a resource request would leave the system in a safe state (where deadlock cannot occur).

10. A safe state in deadlock avoidance implies that:

Correct Answer: b) There exists at least one sequence where all processes can complete

Explanation:
A safe state means the system can allocate resources to each process in some order (at least one sequence exists) without entering a deadlock state.

11. The Resource-Allocation Graph (RAG) is used for deadlock avoidance when:

Correct Answer: b) There is only one instance of each resource

Explanation:
The Resource-Allocation Graph method works only when there's a single instance of each resource type. For multiple instances, the Banker's Algorithm is used.

12. An unsafe state in deadlock avoidance means:

Correct Answer: b) Deadlock may occur if processes request resources improperly

Explanation:
An unsafe state doesn't guarantee deadlock will occur, but means there's a possibility of deadlock if processes request resources in a particular sequence. The system should avoid entering unsafe states.