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.

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Chapter 7: Deadlocks.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 7: Deadlocks.
7.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 7: Deadlocks.
Deadlocks CS 3100 Deadlocks1. The Deadlock Problem A set of blocked processes each holding a resource and waiting to acquire a resource held by another.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 8: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks.
Chapter 7. Deadlocks.
Chapter 7: Deadlocks. 7.2 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks.
1 Chapter 7: Deadlock. 2 The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 7: Deadlock Dr. Mohamed Hefeeda.
02/19/2008CSCI 315 Operating Systems Design1 Deadlock Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks The Deadlock.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 7: Deadlocks.
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.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 7: Deadlock Dr. Mohamed Hefeeda.
What we will cover…  The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Objectives Understand the Deadlock.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Deadlocks.
System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention, Avoidance, and Detection Recovering from Deadlock Combined Approach.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks Modified.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
Chapter 7 Deadlocks. 7.2 Modified By Dr. Khaled Wassif Operating System Concepts – 7 th Edition Silberschatz, Galvin and Gagne ©2005 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.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-6 Deadlocks Department of Computer Science and Software Engineering.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 AE4B33OSS Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization.
CHAPTER 8: DEADLOCKS System Model Deadlock Characterization
 The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock Avoidance  Deadlock.
Dr. Kalpakis CMSC 421, Operating Systems Deadlocks.
Deadlocks System Model RAG Deadlock Characterization
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks System Model Deadlock Characterization Methods.
Mi-Jung Choi Dept. of Computer and Science Silberschatz, Galvin and Gagne ©2006 Operating System Principles Chapter 7: Deadlocks.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 7: Deadlocks.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 7 Operating Systems.
Operating Systems Unit VI Deadlocks and Protection Department of Computer Science Engineering and Information Technology.
Chapter 8 Deadlocks. Objective System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection.
Chapter 7: Deadlocks. 7.2CSCI 380 – Operating Systems Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling.
7.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
CS307 Operating Systems Deadlocks Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2012.
國立台灣大學 資訊工程學系 Chapter 7: Deadlocks. 資工系網媒所 NEWS 實驗室 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes.
Chap 7 Deadlocks. Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks To.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 6 Deadlocks Slide 1 Chapter 6 Deadlocks.
7.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 7: Deadlocks.
Deadlock A deadlock is a situation wherein two or more competing actions are waiting for the other to finish, and thus neither ever does. Example : “When.
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.
7.1 CSE Department MAITSandeep Tayal 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks The Deadlock.
CSE Operating System Principles Deadlocks. CSE – Operating System Principles2 Overview System Model Deadlock Characterization Methods for.
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.
Chapter 7: Deadlocks. The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
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.
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 1/11/2019 B.Ramamurthy.
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 2/23/2019 B.Ramamurthy.
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 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 8/28/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 9/3/2019 B.Ramamurthy.
Presentation transcript:

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 in control. - Anonymous

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

3 §Starvation means there exists a path to making progress but the scheduler is not choosing it. §Deadlock means there is no such path.

4 System Model §Resource types R 1, R 2,..., R m CPU cycles, memory space, I/O devices §Each resource type R i has W i instances. §Resources may be logical as well as physical.

5 Mode of operation Process may utilize a resource in only the following sequence. §Request §Use §Release §Request and release are system calls e.g system calls for allocation and freeing of memory, open and close file system calls, wait and signal on semaphores etc.

6 The Deadlock Problem §A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set. §Example l System has 2 tape drives. l P 1 and P 2 each hold one tape drive and each needs another one. §Example l semaphores A and B, initialized to 1 P 0 P 1 wait (A);wait(B) wait (B);wait(A)

7 Deadlock Characterization §Mutual exclusion: only one process at a time can use a resource. §Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes. §No preemption: a resource can be released only voluntarily by the process holding it, after that process has completed its task. Deadlock can arise if four conditions hold simultaneously.

8 Deadlock Characterization §Circular wait: there exists a set {P 0, P 1, …, P 0 } of waiting processes such that P 0 is waiting for a resource that is held by P 1, P 1 is waiting for a resource that is held by P 2, …, P n–1 is waiting for a resource that is held by P n, and P n is waiting for a resource that is held by P 0. Deadlock can arise if four conditions hold simultaneously.

9 Resource-Allocation Graph §V is partitioned into two types: l P = {P 1, P 2, …, P n }, the set consisting of all the processes in the system. l R = {R 1, R 2, …, R m }, the set consisting of all resource types in the system. §request edge – directed edge P 1  R j §assignment edge – directed edge R j  P i A set of vertices V and a set of edges E.

10 Example of a Resource Allocation Graph

11

12

13 Basic Facts §If graph contains no cycles  no deadlock. §If graph contains a cycle  l if only one instance per resource type, then deadlock. l if several instances per resource type, possibility of deadlock.

14 Mode of operation §System table records whether each resource is free or allocated, and if allocated, to which process §If a process requests a resource that is currently allocated to another process, it can be added to a queue of processes waiting for this resource

15 Handling Deadlocks §Use a protocol to prevent or avoid deadlocks. §Allow a system to enter deadlock state, detect it and recover. §Ignore the problem altogether.

16 Handling Deadlocks §What can happen if processes in the system are in state of undetected deadlock?

17 Deadlock Prevention §Mutual Exclusion §Hold and Wait §No pre-emption §Circular Wait

18 Deadlock Prevention Side effects of deadlock prevention : Low resource utilization and throughput

19 Deadlock Avoidance §Deadlock avoidance requires additional information about about how resources are to be requested. It decides whether the current request is to be satisfied or not. §Decision is based on currently available resources and currently allocated resources and future requests of processes.

20 Deadlock Avoidance §Deadlock Avoidance algorithm requires each process declare the maximum number of resources of each type it might need. §It dynamically examines the resource allocation state to ensure circular wait condition can never exist. §Resource allocation state is defined by: l number of available resources l number of allocated resources l maximum demands of processes

21 Safe State §When a process requests an available resource, system must decide if immediate allocation leaves the system in a safe state. §System is in safe state if there exists a safe sequence of all processes.

22 Safe State §Sequence is safe if for each P i, the resources that Pi can still request can be satisfied by currently available resources + resources held by all the P j, with j<i. l If P i resource needs are not immediately available, then P i can wait until all P j have finished.

23 Safe State l When P j is finished, P i can obtain needed resources, execute, return allocated resources, and terminate. l When P i terminates, P i+1 can obtain its needed resources, and so on. If no such sequence exists, then system state in unsafe.

24 Basic Facts §If a system is in safe state  no deadlocks. §If a system is in unsafe state  possibility of deadlock. §Avoidance  ensure that a system will never enter an unsafe state.

25 Safe, Unsafe, Deadlock State

26 §Example.

27 Resource-Allocation Graph Algorithm §Claim edge P i  R j indicated that process P j may request resource R j ; represented by a dashed line. §Claim edge converts to request edge when a process requests a resource. §Resources must be claimed a priori in the system.

28 Resource-Allocation Graph For Deadlock Avoidance

29 Unsafe State In Resource-Allocation Graph

30 Banker’s Algorithm §Multiple instances. §Each process must a priori claim maximum use. §When a process requests a resource it may have to wait. §When a process gets all its resources it must return them in a finite amount of time.

31 Banker’s Algorithm §Resources requested by process must not exceed the total available in the system. §Algorithm allocates resources if allocation leaves system in a safe state

32 Data Structures for the Banker’s Algorithm §Available: Vector of length m. If available [j] = k, there are k instances of resource type R j available. §Max: n x m matrix. If Max [i,j] = k, then process P i may request at most k instances of resource type R j. Let n = number of processes, and m = number of resources types.

33 Data Structures for the Banker’s Algorithm §Allocation: n x m matrix. If Allocation[i,j] = k then P i is currently allocated k instances of R j. §Need: n x m matrix. If Need[i,j] = k, then P i may need k more instances of R j to complete its task. Need [i,j] = Max[i,j] – Allocation [i,j]. Let n = number of processes, and m = number of resources types.

34 Safety Algorithm 1.Let Work and Finish be vectors of length m and n, respectively. Initialize: Work = Available Finish [i] = false for i - 1,3, …, n. 2.Find and i such that both: (a) Finish [i] = false (b) Need i  Work If no such i exists, go to step 4. 3.Work = Work + Allocation i Finish[i] = true go to step 2. 4.If Finish [i] == true for all i, then the system is in a safe state.

35 Resource-Request Algorithm for Process P i Request = request vector for process P i. If Request i [j] = k then process P i wants k instances of resource type R j. 1.If Request i  Need i go to step 2. Otherwise, raise error condition, since process has exceeded its maximum claim. 2.If Request i  Available, go to step 3. Otherwise P i must wait, since resources are not available.

36 Resource-Request Algorithm for Process P i 3.Pretend to allocate requested resources to P i by modifying the state as follows: Available = Available - Request i ; Allocation i = Allocation i + Request i ; Need i = Need i – Request i If safe  the resources are allocated to P i. If unsafe  P i must wait, and the old resource-allocation state is restored