Deadlock - PowerPoint PPT Presentation

About This Presentation
Title:

Deadlock

Description:

Deadlock Characterization. Methods for Handling Deadlocks. Deadlock Prevention. Deadlock Avoidance ... Deadlock Detection--RAG Reduction. 2. ... – PowerPoint PPT presentation

Number of Views:180
Avg rating:3.0/5.0
Slides: 35
Provided by: aliber
Learn more at: http://cms.dt.uh.edu
Category:

less

Transcript and Presenter's Notes

Title: Deadlock


1
Deadlock
  • Chapter 10

2
Deadlock
  • System Model
  • Deadlock Characterization
  • Methods for Handling Deadlocks
  • Deadlock Prevention
  • Deadlock Avoidance
  • Deadlock Detection Recovery

3
The Deadlock Problem
  • A state where a set of processes are blocked
    each holding a resource and waiting to acquire a
    resource held by another process in the set.
  • Example Semaphores A and B initialized to 1
  • P0 P1
  • wait(A) wait(B)
  • wait(B) wait(A)
  • . ..

4
Process 1 Process 2 Process 3 .
. ... Request (resource1) Request
(resource2) Request (resource3) /holding res
1 / /holding res 2 / /holding res 3 /
.. .. .. Request(resource2)
Request(resource3) Request(resource1) . ..
..
5
System Model
6
Deadlock Characterization
7
Resource Allocation Graph
8
Resource Allocation Graph (cont.)
9
Example of a graph with no cycles
10
Example of a graph with a cycle
11
Basic Facts
12
Methods for handling deadlocks
13
Deadlock Prevention
14
Deadlock Prevention (cont.)
15
Deadlock Avoidance
16
Safe State
17
Basic Facts
18
Banker's Algorithm
19
Data Structures for the Banker's Algorithm
20
Safety Algorithm
Else if no i can be found where Finishiflase
and Needi lt Work , then the system is in an
unsafe state
21
Resource Request Algorithm for Process Pi
22
Example of Banker's Algorithm
23
Example (cont.)
24
Example (cont.) P1 requests (1,0,2)
25
Deadlock Detection
  • Allow system to enter deadlock state
  • Detection Algorithm
  • Recovery scheme

26
Single Instance of Each Resource Type
  • Maintain a resource allocation graph
  • Periodically invoke algorithm that searches for
    cycles in the graph
  • If there is a cycle gt set of processes in cycle
    are in deadlock

27
Deadlock Detection
28
RAG Reduction Algorithm
  • Given the resource allocation graph of the system
    at the current state. Determine if the system is
    in deadlock.
  • 1. if a process is not blocked (i.e. if all
    resources the process is requesting to finish its
    task are available), then reduce graph by that
    process remove the process node from the graph,
    return all its allocated resources, and remove
    all arrows from and to that process.

29
Deadlock Detection--RAG Reduction
30
Deadlock Detection--RAG Reduction
  • 2. Repeat step 1 until all process node are
    removed or the graph can not be reduced any
    further.
  • If a graph can be reduce by all its processes,
    then there is no deadlock
  • If a graph can NOT be completely reduced by all
    its processes then the "irreducible" processes
    constitute the set of deadlocked processes.

31
(No Transcript)
32
Deadlock Detection-- Usage
33
Recovery From Deadlock
34
Recovery From Deadlock
Write a Comment
User Comments (0)
About PowerShow.com