DEADLOCK.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

ICS Principles of Operating Systems Lectures 8 and 9 - Deadlocks Prof. Dmitri V. Kalashnikov dvk ics.uci.edu Slides © Prof. Nalini Venkatasubramanian.
Deadlock Prevention, Avoidance, and Detection.  The Deadlock problem The Deadlock problem  Conditions for deadlocks Conditions for deadlocks  Graph-theoretic.
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
DEADLOCK. Contents  Principles of deadlock  Deadlock prevention  Deadlock detection.
1 Wednesday, June 28, 2006 Command, n.: Statement presented by a human and accepted by a computer in such a manner as to make the human feel that he is.
Chapter 7: Deadlocks. 7.2 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks.
Witawas Srisa-an Chapter 6
CPSC 4650 Operating Systems Chapter 6 Deadlock and Starvation
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 7: Deadlocks.
Deadlocks Gordon College Stephen Brinton. Deadlock Overview The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks.
What we will cover…  The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock.
Deadlock Characterization
Concurrency: Deadlock and Starvation Chapter 6. Goal and approach Deadlock and starvation Underlying principles Solutions? –Prevention –Detection –Avoidance.
1 Concurrency: Deadlock and Starvation Chapter 6.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Deadlocks.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
Cosc 4740 Chapter 6, Part 4 Deadlocks. The Deadlock Problem A set of blocked processes each holding a resource and waiting to acquire a resource held.
CHAPTER 8: DEADLOCKS System Model Deadlock Characterization
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
CS6502 Operating Systems - Dr. J. Garrido Deadlock – Part 2 (Lecture 7a) CS5002 Operating Systems Dr. Jose M. Garrido.
 The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock Avoidance  Deadlock.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks System Model Deadlock Characterization Methods.
Chapter 8 Deadlocks. Objective System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 6 Deadlocks Slide 1 Chapter 6 Deadlocks.
Deadlocks - System Model - Deadlock characterization - Methods for handling deadlocks - Deadlock prevention,avoidance - Deadlock detection and recovery.
Deadlocks 12/02/2015. What is a deadlock ? System has a finite set of resources. Resource can have one or more instances. Processes compete for resources.
Informationsteknologi Monday, October 1, 2007Computer Systems/Operating Systems - Class 111 Today’s class Deadlock.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
Lecture 6 Deadlock 1. Deadlock and Starvation Let S and Q be two semaphores initialized to 1 P 0 P 1 wait (S); wait (Q); wait (Q); wait (S);. signal (S);
Deadlock. Examples You can't get a job without experience; you can't get experience without a job. A set of blocked processes each holding a resource.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
OPERATING SYSTEM CONCEPTS AND PRACTISE
Chapter 7: Deadlocks.
Concurrency: Deadlock and Starvation
ITEC 202 Operating Systems
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks Source & Copyright: Operating System Concepts, Silberschatz, Galvin and Gagne.
Operating Systems (CS 340 D)
Chapter 7: Deadlocks.
Operating System: DEADLOCKS
Chapter 7 Deadlocks.
Chapter 7: Deadlocks.
Process Deadlocks.
Chapter 7: Deadlocks.
Deadlocks Definition A set of processes is in a Deadlock state when every process in the set is waiting for an event that can only be caused by another.
Deadlock B.Ramamurthy CSE421 1/11/2019 B.Ramamurthy.
Lecture 6: Deadlocks, Deadlock Risk Management
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks.
Outline Deadlocks, dead lock prevention, avoidance.
Deadlock Prevention Restrain the ways request can be made.
DPNM Lab. Dept. of CSE, POSTECH
Chapter 8: Deadlocks.
Deadlock B.Ramamurthy CSE421 2/23/2019 B.Ramamurthy.
Deadlocks Session - 13.
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 4/23/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 5/1/2019 B.Ramamurthy.
CSCI 315 Operating Systems Design
Chapter 7: Deadlocks.
Chapter 8: Deadlocks Deadlock Characterization
Deadlock B.Ramamurthy CSE421 8/28/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 9/3/2019 B.Ramamurthy.
Presentation transcript:

DEADLOCK

Contents Principles of deadlock Deadlock prevention Deadlock detection

Deadlock A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause.

P1 P2 R1 R2

Examples of resources: processors,I/O devices, main and secondary memory, files, emaphores…(reusable resources)

Utilization protocol request (the process can be blocked) use release

V(mutex2); P1 P(mutex1); <R1>; P(mutex2); <R2>; <release of R2>; V(mutex1); <release of R1>;

P2 P(mutex2); <R2>; P(mutex1); <R1>; V(mutex1); <release of R1>; V (mutex2); <release of R2>;

A deadlock situation derives from a race condition occurred to some involved processes

Conditions for deadlock P1, P2, … , Pn: a set of processes R1, R2, … , Rm: a set of resource types

A deadlock situation can arise if the following four conditions hold at the same time:

mutual exclusion hold-and-wait no preemption circular wait

All four conditions must hold for deadlock to occur

System resource allocation graph vertices: P=(P1,P2,..,Pn) R=(R1,R2,..,Rm) edges: request edge Pi  Rj assignment edge Rj  Pi

P1 P2 P3 R1 R2 R3

If the graph does not contains cycles, then no process is deadlocked If the graph contain one cycle, then a deadlock may exist

If each resource type has exactly one instance, then a cycle implies that one deadlock has occurred

Each process involved in the cycle is deadlocked (a cycle in the graph is a necessary and sufficient condition for the existence of a deadlock)

If each resource type has several instances, then one cycle does not necessary imply that a deadlock occurred (the cycle is a necessary but not sufficient condition)

P3 R1 P1 P2 R2

Methods for handling deadlock We can use a protocol to ensure hat the system will never enter a deadlock state (deadlock prevention)

We can allow the system to enter a deadlock state and then recover (detection and recovery)

We can ignore the problem, and pretend that deadlocks never occur in the system It is up to the application developer to write programs that handle deadlocks

Deadlock prevention Deadlock prevention is a set of methods for ensuring that at least one of the necessary conditions can never occur

mutual exclusion It is not possible to prevent deadlocks by denying the mutual exclusion condition

hold-and- wait That condition may be prevented by requiring that each process must release all the resources currently allocated before it can request any additional resources.

no preemption If a process that it is holding same resources request another resource that cannot be immediately allocated to it, then all resources currently being held are preempted

circular wait The condition can be prevented by defining a total ordering of all resource types and by requiring that each process requests resources in an increasing order

We associate an index with each resource type Then Ri precedes Rj in the ordering if i<j

Two processes A and B, are deadlocked if A has acquired Ri and requests Rj, and B has acquired Rj and requests Ri

That condition is impossible because it implies i<j and j<i

Deadlock avoidance Deadlock-prevention algorithms prevent deadlocks by constraining the strategy on how requests can be made

Possible side effects of preventing deadlocks by these methods are an inefficient utilization of resources and an inefficient process execution

With deadlock avoidance, a decision is made dynamically whether current resource allocation requests, if granted, would potentially lead to deadlock

The resource allocation state is defined by the number of allocated and available resources and the maximum demands of processes

A safe state is one in which there is at least one process execution sequence such that all processes can be run to completion (safe sequence)

Banker’s algorithm When a process makes a request for a set of resources

assume that the request is granted, update the system state accordingly, and then determine if the result is still a safe state.

If so, grant the request, if not, block the process until it is safe to grant the request

P2 t8 unreachable region safe state R1 t7 safe state A t6 R2 safe state unsafe region t5 safe state safe state P1 t1 t2 t3 t4 R1 R2

Deadlock detection It requires:

an algorithm that examines the state of the system to determine whether a deadlock has occurred an algorithm to recover from the deadlock

Recovery Possible approaches: Abort all deadlocked processes

Back up each deadlocked process to some previously defined check points, and restart all processes form those checkpoints

3.Successively abort deadlocked processes until deadlock not longer exists 4.Successively preempt resources until deadlock not longer exists

For 3 and 4 the selection criteria could be one of the following For 3 and 4 the selection criteria could be one of the following. Choose the process with the:

Least amount of consumed processor time Least amount of produced output

Most estimated remaining time Least total resources allocated so far Lowest priority