Deadlocks MCQs — Operating System

Deadlocks MCQs Operating System


Q1.

Which of the following is not a necessary condition for a deadlock?
A) Mutual Exclusion
B) Circular Wait
C) Preemption
D) Hold and Wait

Answer: C
Solution:
Deadlock occurs when all four conditions (Mutual Exclusion, Hold and Wait, No Preemption, Circular Wait) hold simultaneously.
Preemption being allowed actually helps avoid deadlocks.


Q2.

A system has 5 resources and 3 processes. Each process can request a maximum of 3 resources. Is deadlock possible?
A) Always
B) Never
C) Only if all request simultaneously
D) Depends on allocation

Answer: B
Solution:
Max need = 3 × 3 = 9, available = 5. Since total need < total resources + processes – 1, deadlock cannot occur.


Q3.

Which of the following statements about circular wait is true?
A) It is sufficient but not necessary for deadlock
B) It is necessary but not sufficient for deadlock
C) It can exist without other conditions
D) It ensures no deadlock

Answer: B
Solution:
Circular wait is a necessary condition for deadlock — but alone, it does not guarantee deadlock without other conditions.


Q4.

Which graph is used to detect deadlock in a single instance per resource system?
A) Resource Allocation Graph (RAG)
B) Wait-for Graph
C) Banker’s Graph
D) Communication Graph

Answer: B
Solution:
In a single instance system, the RAG can be reduced to a Wait-for Graph, where a cycle means a deadlock.


Q5.

A system has 4 processes (P1–P4) and 2 resource types (R1, R2).
R1 has 3 instances; R2 has 2.
If P1 and P2 each hold 1 instance of R1 and request 1 more, and R3 holds R2 fully, then:
A) Deadlock must occur
B) No deadlock possible
C) Potential for deadlock
D) Safe state guaranteed

Answer: C
Solution:
If resources are requested in conflicting order, potential for circular wait exists → potential deadlock.


Q6.

Which method prevents deadlock by ensuring resource ordering?
A) Hold and wait prevention
B) Circular wait prevention
C) Mutual exclusion prevention
D) Preemption avoidance

Answer: B
Solution:
Imposing a strict order of resource acquisition prevents circular wait, hence no deadlock.


Q7.

Deadlock avoidance algorithms need:
A) Resource usage pattern beforehand
B) Resource preemption
C) Mutual exclusion disabled
D) Deadlock detection

Answer: A
Solution:
Avoidance requires advance knowledge of maximum resource needs to keep system in a safe state (as in Banker’s Algorithm).


Q8.

A safe state implies:
A) Deadlock
B) No deadlock and possibility to avoid it
C) At least one process blocked
D) Resource starvation

Answer: B
Solution:
Safe state ensures a sequence exists where all processes can complete without deadlock.


Q9.

Which of the following can both detect and recover from deadlock?
A) Banker’s algorithm
B) Deadlock detection algorithm
C) Resource allocation graph
D) None

Answer: B
Solution:
Detection algorithms identify cycles, and recovery can be performed via process termination or rollback.


Q10.

To ensure no preemption, a resource can be released only:
A) Voluntarily by process
B) By OS forcibly
C) When process crashes
D) When requested by another process

Answer: A
Solution:
“No preemption” means once a process holds a resource, it must voluntarily release it.


Q11.

Which is the most practical approach used in real systems?
A) Deadlock prevention
B) Deadlock avoidance
C) Deadlock detection and recovery
D) Ignoring deadlock

Answer: D
Solution:
Most OSs (like UNIX, Windows) ignore deadlock due to its rare occurrence and complexity of prevention.


Q12.

If a system has a cycle in its Resource Allocation Graph, it implies:
A) Deadlock
B) No deadlock possible
C) Potential deadlock (only if multiple instances per resource)
D) Starvation

Answer: C
Solution:
If single instance per resource → cycle = deadlock;
If multiple instances, cycle = possibility of deadlock.


Q13.

In Banker’s algorithm, if Available = [2, 1, 0] and Need(P2) = [1, 1, 0], can P2 safely execute?
A) Yes
B) No
C) Only if another process completes
D) Not enough info

Answer: A
Solution:
Available ≥ Need(P2) → P2 can execute, release resources → system remains safe.


Q14.

Which algorithm requires the system to be aware of maximum claims?
A) Detection
B) Prevention
C) Avoidance
D) Recovery

Answer: C
Solution:
Avoidance (e.g., Banker’s) uses declared maximum needs to ensure safe sequences.


Q15.

Which of the following is not a deadlock handling method?
A) Ignore
B) Prevention
C) Detection and Recovery
D) Resource virtualization

Answer: D
Solution:
Resource virtualization helps in abstraction, not deadlock handling.


Q16.

In Banker’s algorithm, system state changes after:
A) Request
B) Allocation
C) Release
D) Both A and B

Answer: D
Solution:
The state changes when requests or releases happen — system re-evaluates for safety.


Q17.

To recover from deadlock, preemption is used by:
A) Removing all processes
B) Forcing resource release
C) Killing processes
D) Restarting system

Answer: B
Solution:
Preemption forces resource release, breaking the hold-and-wait condition.


Q18.

Which of these is not a recovery technique?
A) Process termination
B) Rollback
C) Checkpointing
D) Banker’s scheduling

Answer: D
Solution:
Banker’s is an avoidance algorithm, not recovery.


Q19.

Which of the following may cause starvation even when deadlock is avoided?
A) Resource ordering
B) Process priority scheduling
C) Circular wait
D) Preemption

Answer: B
Solution:
Prioritizing high-priority processes can cause low-priority starvation despite no deadlock.


Q20.

Which statement about safe sequence is true?
A) Every safe sequence ensures deadlock
B) Every safe sequence avoids deadlock
C) Unsafe sequence implies deadlock
D) Safe sequence = unsafe

Answer: B
Solution:
In a safe sequence, processes can complete sequentially → no deadlock.


Q21.

If all processes request their maximum resources simultaneously, what can prevent deadlock?
A) Circular wait
B) Hold and wait prevention
C) Resource preemption
D) None

Answer: B
Solution:
Disallowing hold-and-wait (by requesting all resources at once) prevents deadlock.


Q22.

The Wait-for Graph has a cycle involving P1, P2, P3. Deadlock exists only if:
A) Single instance per resource
B) Multiple instances per resource
C) There are more than 3 processes
D) Each process holds two resources

Answer: A
Solution:
A cycle indicates deadlock only in single-instance systems.


Q23.

Which of the following is used to avoid hold and wait?
A) Preemption
B) Resource ordering
C) Request all resources at once
D) Circular wait removal

Answer: C
Solution:
Requiring a process to request all resources simultaneously removes hold-and-wait.


Q24.

Which of these strategies can result in low resource utilization?
A) Deadlock avoidance
B) Deadlock prevention
C) Detection
D) Recovery

Answer: B
Solution:
Prevention restricts concurrency (e.g., requesting all resources at once) → low utilization.


Q25.

Which of the following pairs are not mutually exclusive?
A) Safe state and deadlock
B) Unsafe state and deadlock
C) Safe state and unsafe state
D) Safe state and recovery

Answer: B
Solution:
An unsafe state may or may not lead to deadlock — they’re not mutually exclusive.

Q26.

A system with 4 processes (P1–P4) and 3 resource types (R1–R3) shows a cycle in its Wait-for Graph. This indicates:
A) System is definitely in deadlock
B) System is deadlock-free
C) System may be in deadlock
D) Cannot determine without resource instances

Answer: C
Solution:
If multiple instances of resources exist, a cycle in WFG means possible, not definite, deadlock.


Q27.

If all resources are preemptable, deadlock:
A) Can still occur
B) Cannot occur
C) Depends on scheduling
D) Requires detection

Answer: B
Solution:
If resources can be forcibly taken, hold and wait is broken → deadlock cannot occur.


Q28.

Which of the following is not a possible method of recovery from deadlock?
A) Preempting resources
B) Killing one or more processes
C) Ignoring the deadlock
D) Restarting system

Answer: C
Solution:
Ignoring deadlock is not recovery; it’s deadlock ignorance (ostrich approach).


Q29.

In a system using Banker’s algorithm, a state is safe if:
A) There is a deadlock
B) There is at least one safe sequence
C) No resources are allocated
D) All processes are waiting

Answer: B
Solution:
Safe state means there exists at least one safe sequence where all processes can complete.


Q30.

Which of the following may lead to livelock but not deadlock?
A) Busy waiting
B) Hold and wait
C) Circular wait
D) Mutual exclusion

Answer: A
Solution:
Livelock occurs when processes keep changing states (busy waiting) without progress — unlike deadlock.


Q31.

If a process is preempted and rolled back to a safe state, this technique is called:
A) Prevention
B) Avoidance
C) Detection and recovery
D) Resource ordering

Answer: C
Solution:
Rollback recovery is part of detection and recovery strategies.


Q32.

In the Resource Allocation Graph (RAG), what does a cycle represent when each resource has only one instance?
A) Unsafe state
B) Deadlock
C) Livelock
D) Starvation

Answer: B
Solution:
In single-instance systems, a cycle directly implies deadlock.


Q33.

Which is the simplest way to break a deadlock cycle?
A) Remove hold and wait
B) Kill a process
C) Disable interrupts
D) Release all resources

Answer: B
Solution:
Killing one process involved in the cycle releases resources, breaking the deadlock.


Q34.

To ensure system safety, the Banker’s algorithm simulates allocation to check:
A) Deadlock existence
B) Safe sequence possibility
C) Resource usage
D) Priority inversion

Answer: B
Solution:
Banker’s algorithm checks for at least one safe sequence before granting requests.


Q35.

If a system enters an unsafe state, then:
A) Deadlock will definitely occur
B) Deadlock may or may not occur
C) Deadlock can never occur
D) System halts immediately

Answer: B
Solution:
Unsafe ≠ Deadlock. It only means risk of deadlock exists.


Q36.

Which of the following is not an advantage of deadlock avoidance?
A) Resources utilized effectively
B) No starvation
C) Deadlocks avoided
D) No need for rollback

Answer: B
Solution:
Avoidance may still lead to starvation, especially for long-waiting processes.


Q37.

The Banker’s algorithm is named because it resembles:
A) Banker allocating cash safely
B) Process scheduling
C) Memory allocation
D) Transaction processing

Answer: A
Solution:
It’s like a banker ensuring enough cash (resources) remains to satisfy all future claims safely.


Q38.

Which of the following cannot prevent deadlock?
A) Request all resources at once
B) Preemption of resources
C) Increasing resource instances
D) Decreasing resource instances

Answer: D
Solution:
Reducing available instances increases deadlock risk.


Q39.

A deadlock-free system is always in a safe state. True or False?
A) True
B) False

Answer: B
Solution:
A system may be deadlock-free but unsafe (deadlock not yet occurred but possible).


Q40.

Which deadlock condition is easiest to violate?
A) Mutual exclusion
B) Hold and wait
C) No preemption
D) Circular wait

Answer: B
Solution:
Disallowing hold and wait (request all at once) is simple but inefficient.


Q41.

In a system of 5 processes and 3 resources, if the total demand is less than the total instances, can deadlock occur?
A) Yes
B) No
C) Only in unsafe state
D) Cannot determine

Answer: B
Solution:
If total demand < total instances, deadlock cannot occur (enough resources).


Q42.

A process termination recovery strategy is risky because:
A) It may terminate critical processes
B) It requires rollback
C) It uses preemption
D) It needs resource ordering

Answer: A
Solution:
Terminating arbitrary processes may kill critical ones → unstable recovery.


Q43.

In Banker’s Algorithm, if Need = 0 for a process, then:
A) It’s complete
B) It can immediately execute
C) It must wait
D) It’s deadlocked

Answer: B
Solution:
If Need = 0, all resources already held → process can complete immediately.


Q44.

Which of the following strategies can cause low CPU utilization?
A) Prevention
B) Avoidance
C) Detection
D) Recovery

Answer: A
Solution:
Prevention often keeps resources idle → low utilization.


Q45.

In a wait-for graph, if there are no cycles, then:
A) Deadlock exists
B) System is deadlock-free
C) Unsafe
D) Resources are overused

Answer: B
Solution:
No cycles ⇒ no deadlock (since circular wait is absent).


Q46.

Which of the following is the most expensive deadlock handling technique?
A) Prevention
B) Avoidance
C) Detection and recovery
D) Ignorance

Answer: C
Solution:
Detection and recovery involves frequent checks and rollbacks → high overhead.


Q47.

What is the main difference between starvation and deadlock?
A) Deadlock halts all, starvation halts few
B) Starvation involves circular wait
C) Deadlock can be temporary
D) Starvation requires resource preemption

Answer: A
Solution:
In deadlock, all are stuck; in starvation, some wait indefinitely while others proceed.


Q48.

To detect deadlock in systems with multiple resource instances, we use:
A) Wait-for Graph
B) Resource Allocation Matrix
C) Banker’s algorithm
D) Detection matrix

Answer: D
Solution:
Detection matrix algorithms handle multiple instances — modified version of Banker’s.


Q49.

Which is not true for resource preemption recovery?
A) Saves process state
B) Involves rollback
C) Reduces resource utilization
D) Works for non-preemptable resources

Answer: D
Solution:
Preemption works only for preemptable resources (like CPU, not printers).


Q50.

Circular wait can be prevented by:
A) Assigning a unique number to each resource
B) Disabling interrupts
C) Reducing priority
D) Using preemption

Answer: A
Solution:
Enforcing resource ordering (unique numbering) removes circular wait possibility.


Q51.

A deadlock can occur only when:
A) Resources are sharable
B) Resources are non-sharable
C) Processes are independent
D) None

Answer: B
Solution:
Deadlocks occur only with non-sharable resources.


Q52.

A system has 2 resources and 2 processes, both requesting both resources. Deadlock can be avoided by:
A) Granting both simultaneously
B) Granting one and denying other
C) Random allocation
D) Sequential granting

Answer: D
Solution:
Granting resources in fixed order avoids circular wait.


Q53.

The Ostrich algorithm means:
A) Ignoring deadlocks
B) Preventing deadlocks
C) Detecting deadlocks
D) Recovering from deadlocks

Answer: A
Solution:
Named after ostrich burying its head — the OS ignores deadlocks.


Q54.

Which of these systems is least likely to experience deadlocks?
A) Single-user batch
B) Multiprogramming
C) Time-sharing
D) Distributed

Answer: A
Solution:
In single-user batch systems, one process runs at a time → no competition → no deadlock.


Q55.

Which deadlock prevention technique may cause resource underutilization?
A) Request all at once
B) Preemption
C) Resource ordering
D) Detection

Answer: A
Solution:
Requesting all resources at once blocks others and leads to poor utilization.


Q56.

The Banker’s algorithm is suitable only for:
A) Real-time systems
B) Static systems
C) Systems with known maximum needs
D) Systems with dynamic allocation

Answer: C
Solution:
Banker’s requires knowing each process’s maximum claim in advance.


Q57.

If a system is in an unsafe state, then:
A) Deadlock is certain
B) Deadlock is possible
C) Deadlock is impossible
D) System halts

Answer: B
Solution:
Unsafe means potential for deadlock, not certainty.


Q58.

Which of the following cannot be preempted safely?
A) CPU
B) Memory
C) Printer
D) Disk

Answer: C
Solution:
Printer outputs cannot be saved mid-operation — non-preemptable.


Q59.

If deadlock is detected, but the OS waits for some time before acting, this is called:
A) Lazy detection
B) Wait-and-see recovery
C) Periodic recovery
D) Safe delay

Answer: B
Solution:
Wait-and-see allows processes to complete naturally before forced recovery.


Q60.

Which of the following algorithms checks safety before allocation?
A) Banker’s
B) Detection
C) Recovery
D) Ignorance

Answer: A
Solution:
Banker’s checks safety prior to granting requests.


Q61.

When can the detection algorithm be run?
A) Every time a resource is requested
B) Periodically
C) Randomly
D) When system is idle

Answer: B
Solution:
Detection is run periodically to balance overhead and responsiveness.


Q62.

If resources are allocated dynamically, which technique is preferred?
A) Prevention
B) Avoidance
C) Detection
D) Ignorance

Answer: C
Solution:
Dynamic allocation suits detection & recovery better than static avoidance.


Q63.

A process waiting indefinitely due to resource preemption is said to be in:
A) Starvation
B) Deadlock
C) Unsafe state
D) Circular wait

Answer: A
Solution:
Starvation occurs when a process never gets resources though deadlock is absent.


Q64.

If a system has m resources and n processes, the maximum deadlock-free allocation occurs when:
A) m ≥ n
B) m ≥ n − 1
C) m < n
D) n = 2m

Answer: B
Solution:
At least n−1 resources needed to avoid deadlock in circular wait scenarios.


Q65.

Which algorithm is used for deadlock detection in multiple-instance systems?
A) Banker’s
B) Wait-for
C) Detection matrix algorithm
D) Monitor algorithm

Answer: C
Solution:
Detection matrix tracks allocation, request, and available matrices.


Q66.

The main disadvantage of Banker’s algorithm is:
A) Inefficiency
B) High CPU usage
C) Need for prior knowledge of maximum needs
D) Low memory use

Answer: C
Solution:
Maximum claim must be known beforehand, often impractical.


Q67.

Which of the following techniques ensures both safety and efficiency?
A) Prevention
B) Detection
C) Combined detection & prevention
D) Avoidance

Answer: D
Solution:
Avoidance keeps system safe while maintaining good resource use.


Q68.

A system has 10 tape drives, 3 processes, each may need 5 drives. Is deadlock possible?
A) Yes
B) No
C) Only if all hold 4
D) Not enough info

Answer: B
Solution:
Max need < total + processes − 1 ⇒ deadlock impossible.


Q69.

A system with 4 processes and 4 identical resources is deadlock-free if:
A) Each holds at most one resource
B) Each requests 2 resources
C) All request simultaneously
D) Each holds all resources

Answer: A
Solution:
One resource per process eliminates circular dependency.


Q70.

In deadlock detection, what does an edge from P1 → P2 mean?
A) P1 waiting for P2’s resource
B) P2 waiting for P1
C) Both in deadlock
D) P1 holds P2

Answer: A
Solution:
P1 → P2 means P1 is waiting for a resource held by P2.


Q71.

To prevent circular wait, the OS enforces:
A) Resource numbering
B) Preemption
C) Timeout
D) Interrupt disabling

Answer: A
Solution:
Assigning numbers removes circular dependency.


Q72.

Which of the following resources is preemptable?
A) Disk
B) CPU
C) Printer
D) Plotter

Answer: B
Solution:
CPU can be taken away safely via context switching.


Q73.

The recovery method that saves state and restarts is:
A) Rollback
B) Termination
C) Detection
D) Prevention

Answer: A
Solution:
Rollback restores process to previous checkpoint.


Q74.

Which algorithm can result in starvation even without deadlock?
A) Banker’s
B) Prevention
C) Detection
D) Avoidance

Answer: B
Solution:
Prevention restricts resource usage — some processes may never proceed.


Q75.

If a process requests a resource immediately upon start, it helps prevent:
A) Circular wait
B) Hold and wait
C) Deadlock
D) Starvation

Answer: B
Solution:
Requesting all upfront removes hold and wait condition.


Q76.

If two processes each hold one resource and need one more, the system:
A) Is safe
B) Is in deadlock
C) Is unsafe but not deadlocked
D) Has high utilization

Answer: C
Solution:
System may become unsafe if both wait indefinitely.


Q77.

Which deadlock condition does resource preemption violate?
A) Mutual exclusion
B) Hold and wait
C) No preemption
D) Circular wait

Answer: C
Solution:
Preemption breaks “no preemption” condition.


Q78.

Deadlock in databases corresponds to:
A) Lock contention
B) Transaction serialization
C) Cascading rollback
D) Phantom reads

Answer: A
Solution:
Deadlock occurs when transactions lock resources cyclically.


Q79.

To detect deadlock, which data structure tracks resource usage?
A) Allocation matrix
B) Process tree
C) Job queue
D) Page table

Answer: A
Solution:
The allocation matrix records which process holds which resource.


Q80.

A process releasing all resources after each use helps prevent:
A) Deadlock
B) Starvation
C) Livelock
D) Preemption

Answer: A
Solution:
No resource held while waiting → no hold and wait.


Q81.

Deadlock and starvation differ mainly in:
A) Mutual exclusion
B) Waiting time
C) Priority
D) Process termination

Answer: B
Solution:
Starvation = long wait; deadlock = infinite wait (no progress).


**