---
title: "Deadlock conditions; recovery methods"
subject: "Operating System"
chapter: 7
key: "semester_6/operating_system:deadlock-resource-conditions-recovery"
source: https://www.bctengineer.com/q/semester_6/operating_system/deadlock-resource-conditions-recovery
site: BCT Engineering
---

# Deadlock conditions; recovery methods

Operating System · Chapter 7: Deadlock

- Asked in: year not given
- Video: [Lec26 Deadlock Recovery in Operating System](https://www.youtube.com/watch?v=bQBt1IYMscI) — Jenny's Lectures CS IT
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/operating_system/deadlock-resource-conditions-recovery
- Whole chapter: https://www.bctengineer.com/md/semester_6/operating_system/chapter-7

## Question

Define deadlock. What are the conditions for resource deadlock? Explain some methods for recovery from deadlock.

## Short answer

Deadlock occurs when each process in a set waits for a resource held by another in the set. The four conditions are mutual exclusion, hold and wait, no preemption, and circular wait. Recovery methods include resource preemption (taking resources from a process), rollback to checkpoints (restarting a process from a saved state), and killing deadlocked processes (terminating one or all processes in the cycle).

## Answer

#### Deadlock
A set of processes is deadlocked if each process is waiting for an event (release of a resource) that can be caused only by another process in the set.

#### Conditions for resource deadlock (Coffman)
1. **Mutual exclusion:** each resource is either assigned to exactly one process or is available.
2. **Hold and wait:** processes holding earlier-granted resources may request new ones.
3. **No preemption:** resources previously granted cannot be forcibly taken away.
4. **Circular wait:** a circular chain of two or more processes exists, each waiting for a resource held by the next one.

#### Recovery from deadlock
1. **Recovery through preemption:** temporarily take a resource away from its owner and give it to another process. This often needs manual intervention and depends on the resource (e.g. suspending a process and giving its printer to another is difficult, but taking memory by swapping is possible).
2. **Recovery through rollback:** processes are checkpointed regularly (state and resources saved in files). On deadlock, a process that owns a needed resource is rolled back to a checkpoint before it acquired it, and the resource is given to a waiting process.
3. **Recovery through killing processes:** the simplest. Kill one process in the cycle, or all of them. The victim should be one that can be rerun without bad effects (e.g. a compile, not a database update). The process is chosen using priority, run time, and resources held.

After recovery, care is needed to avoid starvation, so the same victim is not chosen repeatedly.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which defines a deadlocked set of processes?
   A. One process waits for the CPU for a long time
   B. Each waits for an event that only another process in the set can cause
   C. All processes terminate abnormally
   D. A process waits for user input
   Answer: B. Deadlock is mutual waiting within a set. (Key point: Deadlock definition)

2. What does 'no preemption' mean?
   A. Each resource is given to one process only
   B. A process requests new resources while holding old ones
   C. Granted resources cannot be forcibly taken away
   D. Processes form a waiting circle
   Answer: C. Resources are released only voluntarily. (Key point: No preemption)

3. How does recovery through rollback work?
   A. All processes are restarted from scratch
   B. Resources are numbered and requests reordered
   C. A firewall blocks the cycle
   D. A process holding a needed resource is rolled back to an earlier checkpoint, freeing the resource
   Answer: D. Regular checkpoints let the system restart a process from before it acquired the resource. (Key point: Rollback recovery)

4. Which victim is best when killing a process?
   A. One that can be rerun without bad effects, e.g. a compile rather than a database update
   B. A database update, as it holds the most
   C. Always the highest-priority process
   D. The process that just started
   Answer: A. Choosing a safely rerunnable process avoids damage. (Key point: Choosing a victim for killing)

## Related in Operating System

- [Four deadlock conditions; prevention, recovery](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adeadlock-conditions-prevention-recovery) — Operating System, chapter 7
- [Deadlock conditions; Banker's with 4 processes](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afour-conditions-banker-p1-p4) — Operating System, chapter 7
- [Deadlock; necessary conditions with examples](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adeadlock-necessary-conditions-examples) — Operating System, chapter 7
- [Deadlock conditions and why all necessary](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adeadlock-conditions-why-necessary) — Operating System, chapter 7
- [Deadlock conditions, detection, action](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adeadlock-conditions-detection-recovery-action) — Operating System, chapter 7
- [Deadlock conditions; Banker's safe sequence](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afour-conditions-banker-snapshot-332) — Operating System, chapter 7

## Related in other subjects

- [Distributed deadlock and recovery](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Adistributed-deadlock-note) — Distributed System, chapter 8, asked 3×
- [Deadlock and Coffman conditions](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Acoffman-deadlock) — Embedded System, chapter 6, asked 4×
- [Deadlock and its conditions](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Adeadlock-conditions) — Microprocessor, chapter 6, asked 2×
