You are on page 1of 4

GeeksforGeeks

A computer science portal for geeks

Custom Search
search
Practice GATE CS Placements Videos Contribute

Login/Register
Skip to content
Algo DS Languages Interview Students GATE CS Subjects
Quizzes GBlog Puzzles Whats New?
Quick Links for Operating Systems
Recent Articles
MCQ / Quizzes
Practice Problems
Last Minute Notes (LMNs)

Basics
What happens when we turn on computer?
Explore More...
Processes & Threads
Process - Introduction
Thread
User Level thread vs. Kernel Level thread
Zombie Processes and their Prevention
Maximum number of Zombie process a system can handle
Maximum number of threads that can be created within a process in C
What exactly Spooling is all about?
Multi threading models
Explore More...
Process Synchronization
Introduction & Critical Section
Inter Process Communication
Mutex vs Semaphore & Monitors
Petersons Algorithm for Mutual Exclusion | Set 1 & Set 2
Readers-Writers Problem
Priority Inversion : What the heck !
Bankers Algorithm & Program
Priority Inversion vs. Priority Inheritance
Explore More...
CPU Scheduling
Process Management - Introduction
CPU Scheduling & Process Scheduler
FCFS Scheduling | Set 1 & Set 2
SJF scheduling
Round Robin scheduling
Priority Scheduling
Explore More...
Deadlocks
Introduction
Detection And Recovery
Prevention And Avoidance
Explore More...
Memory Management
Partition Allocation Method
Virtual Memory
Paging
Segmentation
Page Replacement Algorithms
Static and Dynamic Libraries
Working with Shared Libraries | Set 1 & Set 2
Explore More...
File & Disk Management
File System
File Allocation Methods
Disk Scheduling Algorithms
Explore More...
Linux
Linux File Hierarchy Structure
Initializing and Cache Mechanism in Linux Kernel
Some useful Linux Hacks
Explore More...
Deadlock Detection And Recovery
In the previous post, we have discussed Deadlock Prevention and Avoidance. In this
post, Deadlock Detection and Recovery technique to handle deadlock is discussed.

Deadlock Detection

1. If resources have single instance:


In this case for Deadlock detection we can run an algorithm to check for cycle in
the Resource Allocation Graph. Presence of cycle in the graph is the sufficient
condition for deadlock.
deadlock

In the above diagram, resource 1 and resource 2 have single instances. There is a
cycle R1?>P1?>R2?>P2. So Deadlock is Confirmed.

2. If there are multiple instances of resources:


Detection of cycle is necessary but not sufficient condition for deadlock
detection, in this case system may or may not be in deadlock varies according to
different situations.

Deadlock Recovery
Traditional operating system such as Windows doesnt deal with deadlock recovery
as it is time and space consuming process. Real time operating systems use Deadlock
recovery.

Recovery method

1. Killing the process.

killing all the process involved in deadlock.

Killing process one by one. After killing each


process check for deadlock again keep repeating
process till system recover from deadlock.
2. Resource Preemption
Resources are preempted from the processes involved in deadlock, preempted
resources are allocated to other processes, so that their is a possibility of
recovering the system from deadlock. In this case system go into starvation.

See Quiz on Deadlock.

Please write comments if you find anything incorrect, or you want to share more
information about the topic discussed above
GATE CS Corner Company Wise Coding Practice

Operating Systems Deadlocks


Recommended Posts:

Deadlock Prevention And Avoidance


Operating System | Process Management | Deadlock Introduction
Zombie Processes and their Prevention
Operating System | Memory Management |Partition Allocation Method
Process Synchronization | Monitors

Post navigation<< Previous PostNext Post >>


(Login to Rate and Mark)

2 Average Difficulty : 2/5.0


Based on 1 vote(s)

Add to TODO List


Mark as DONE

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share
the link here.

Load Comments
Share this post!

Trending Content
Pairwise swap elements of a given linked list
Longest Consecutive Subsequence
C-Advanced Pointer
GATE | GATE 2017 MOCK II | Question 38
Data Structures | Queue | Question 11
Pattern Searching | Set 7 (Boyer Moore Algorithm ? Bad Character Heuristic)
The Celebrity Problem
Sorted Linked List to Balanced BST
Count distinct elements in every window of size k
Myntra Interview Experience | Set 5
ProGeek Cup 1.0

Most Visited Posts


Top 10 Algorithms and Data Structures for Competitive Programming
Top 10 algorithms in Interview Questions
How to begin with Competitive Programming?
Step by Step Guide for Placement Preparation
How to prepare for ACM-ICPC?
Insertion Sort, Binary Search, QuickSort, MergeSort, HeapSort

ads by BSA
Popular Categories
Interview Experiences
Advanced Data Structures
Dynamic Programming
Greedy Algorithms
Backtracking
Pattern Searching
Divide & Conquer
Geometric Algorithms
Searching
Sorting
Analysis of Algorithms
Mathematical Algorithms
Randomized Algorithms
Recursion
Game Theory
Tags
Advanced Data Structure Amazon Aptitude Aptitude Arrays Bit Magic C C C++ C++ Quiz
CPP-Library C Quiz Data Structures Data Structures DBMS Dynamic Programming
Experienced GATE-CS-2012 GBlog Graph Hash Internship Interview Experiences Java
java- Java Quiz Linked Lists Mathematical Matrix MCQ Microsoft number-digits
Program Output Project Puzzles Python QA - Placement Quizzes QA - Placement Quizzes
School Programming Searching Sorting STL Strings Technical Scripter Trees
Advertise Here
Recent Comments
@geeksforgeeks, Some rights reserved Contact Us! About Us!
Advertise with us! Privacy Policy

You might also like