A. Berrached::cms::uhd Deadlock Chapter 10 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd Deadlock System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection & Recovery 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd 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); …. ….. 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd 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); …. ….. ….. 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd System Model 10/2/2019 A. Berrached::cms::uhd
Deadlock Characterization 10/2/2019 A. Berrached::cms::uhd
Resource Allocation Graph 10/2/2019 A. Berrached::cms::uhd
Resource Allocation Graph (cont.) 10/2/2019 A. Berrached::cms::uhd
Example of a graph with no cycles 10/2/2019 A. Berrached::cms::uhd
Example of a graph with a cycle 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd Basic Facts 10/2/2019 A. Berrached::cms::uhd
Methods for handling deadlocks 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd Deadlock Prevention 10/2/2019 A. Berrached::cms::uhd
Deadlock Prevention (cont.) 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd Deadlock Avoidance 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd Safe State 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd Basic Facts 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd Banker's Algorithm 10/2/2019 A. Berrached::cms::uhd
Data Structures for the Banker's Algorithm 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd Safety Algorithm Else if no i can be found where Finish[i]=flase and Needi <= Work , then the system is in an unsafe state 10/2/2019 A. Berrached::cms::uhd
Resource Request Algorithm for Process Pi 10/2/2019 A. Berrached::cms::uhd
Example of Banker's Algorithm 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd Example (cont.) 10/2/2019 A. Berrached::cms::uhd
Example (cont.): P1 requests (1,0,2) 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd Deadlock Detection Allow system to enter deadlock state Detection Algorithm Recovery scheme 10/2/2019 A. Berrached::cms::uhd
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 ==> set of processes in cycle are in deadlock 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd Deadlock Detection 10/2/2019 A. Berrached::cms::uhd
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. 10/2/2019 A. Berrached::cms::uhd
Deadlock Detection--RAG Reduction 10/2/2019 A. Berrached::cms::uhd
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. 10/2/2019 A. Berrached::cms::uhd
A. Berrached::cms::uhd 10/2/2019 A. Berrached::cms::uhd
Deadlock Detection-- Usage 10/2/2019 A. Berrached::cms::uhd
Recovery From Deadlock 10/2/2019 A. Berrached::cms::uhd
Recovery From Deadlock 10/2/2019 A. Berrached::cms::uhd