11 Resource Management Deadlock and Starvation

Size: px
Start display at page:

Download "11 Resource Management Deadlock and Starvation"

Transcription

1 11 Resource Management Deadlock and Starvation Examples, Deadlock Conditions, Policies against Deadlocks Winter Term 2004/2005 Gerd Liefländer 2003 Universität Karlsruhe, System Architecture Group 1

2 Recommended Reading:! Bacon, J.: Operating Systems (11, 18)! Nehmer, J.: Grundlagen moderner BS (6, 7, 8)! Silberschatz, A.: Operating System Concepts (7)! Stallings, W.: Operating Systems, 6! Tanenbaum, A.: Modern Operating Systems (3) 2003 Universität Karlsruhe, System Architecture Group 2

3 Overview Roadmap for Today! Motivation! Introduction! Examples! Resource Management! Deadlock Conditions! Policies against Deadlocks 2003 Universität Karlsruhe, System Architecture Group 3

4 Overview First View on Deadlocks Continuous mutual blocking of a set of threads either competing for resources or interacting with each other (via synchronization, cooperation or communication) Conflicting requests by at least 2 threads Current research status: No satisfying solution in all cases Some standard OSes don t bother deadlocks at all (e.g. SUN s OS) arguing that deadlocks will occur scarcely 2003 Universität Karlsruhe, System Architecture Group 4

5 Traffic Deadlock Question: a simple rule to avoid the above situation? 2003 Universität Karlsruhe, System Architecture Group 5

6 Motivation Example of a Deadlock If cars arrive at same time no official protocol solving this problem Universität Karlsruhe, System Architecture Group 6

7 Motivation Another Example of a Deadlock? No, this is called a live lock Live locked threads may run forever in a spin lock (riving up the engine) or they may be in a blocked state. Both situations might lead to starvation (at least if fuel is out) Universität Karlsruhe, System Architecture Group 7

8 Examples Examples of Deadlocks: Nested CS semaphore s1 = 1, s2 = 1; Thread T1 { p(s1); /* outer CS */ p(s2); /* inner CS */ v(s2); v(s1); } Thread T2 { p(s2); /* outer CS */ p(s1); /* inner CS */ v(s1); v(s2); } Some authors claim: Nested CSs are severe design errors 2003 Universität Karlsruhe, System Architecture Group 8

9 Late Signaling, Circular Resource Allocation Examples Thread1 Thread2 Thread1 Thread2 Wait(S 1 ) Wait(S 2 ) Allocate(R 1 ) Allocate(R 2 ) Signal(S 2 ) Signal(S 1 ) Allocate(R 2 ) Allocate(R 1 ) This is a program error However, if thread 1 and thread 2 belong to different applications? Is this also a program error? Yes, this timing may lead to deadlock 2003 Universität Karlsruhe, System Architecture Group 9

10 Examples Examples of Deadlocks Thread1 Allocate(R 1 ) What will happen? Allocate(R 2 ) Thread2 Nevertheless, that program is incorrect because it can result in a deadlock. Allocate(R 2 ) Allocate(R 1 ) Is this also a program error? Can also run without a deadlock! Deadlock analysis always requires worst case scenario Universität Karlsruhe, System Architecture Group 10

11 Examples Another Deadlock due to Resource Allocation Assumption: System offers 10 memory frames Thread1 Thread2 Allocate(5) Allocate(5) Allocate(1) Allocate(1) Remark: Again, the system can result in an deadlock, but does not necessary run into a deadlock 2003 Universität Karlsruhe, System Architecture Group 11

12 Examples Some Comments on Deadlocks! In addition, deadlock is not possible between two threads in a process, because it is the process that holds resources, not the thread that is, each thread has access to the resources held by the process. ( Rashid Bin Muhammad )! Crises and deadlocks when they occur have at least this advantage, that they force us to think. - Jawaharlal Nehru ( ) Indian political leader! 2003 Universität Karlsruhe, System Architecture Group 12

13 Resource Management Resource Management (1) Resource manager is a monitor with interface operations: 1. allocate(r: resource) and release(r: resource) if resource is exclusive as one non-sharable unit (~can be allocated to 1 thread, only, e.g. a printer) Remark: There are analogies between resource management and critical sections (especially exclusive resources) 2003 Universität Karlsruhe, System Architecture Group 13

14 Resource Management Resource Management (2) 2. allocate(r:resource, p:integer, a: address) release(r:resource, p:integer, a:address) if the resource can be allocated piece by piece, e.g. frames of main memory, p specifies the number of contiguous frames etc., a specifies the address of the first entity Universität Karlsruhe, System Architecture Group 14

15 Resource Management Resource Management enter_section exit_section allocate release Data structures for resource management 2003 Universität Karlsruhe, System Architecture Group 15

16 Resource Management Resources Types! Logical Resources! Buffer! Container! File! Directory!...! Physical Resources! Memory (Cache, Main, Disk, )! Network! Printer! Display! Keyboard! Universität Karlsruhe, System Architecture Group 16

17 Resource Management Utilization Protocol (1) allocate use use use use release time Remark: Utilization of an exclusive resource ~ handling of a CS i.e. Allocate ~ EnterCriticalSection and Release ~ LeaveCriticalSection 2003 Universität Karlsruhe, System Architecture Group 17

18 Resource Management Utilization Protocol (2) allocate use use use use release thread T1 allocate T1 may hand over the resource to T2 thread T2 T2 has to wait until T1 releases the resource 2003 Universität Karlsruhe, System Architecture Group 18

19 Resource Management Resources (1)! Deadlocks may occur when! processes are granted exclusive access to devices! we refer to these devices generally as resources! Preemptable resources! can be taken away from a process with no ill effects! Nonpreemptable resources! will cause the process to fail if taken away 2003 Universität Karlsruhe, System Architecture Group 19

20 Resource Management Resources (2)! Sequence of events required to use a resource 1. request the resource 2. use the resource 3. release the resource! Must wait if request is denied! requesting process may be blocked! may fail with error code 2003 Universität Karlsruhe, System Architecture Group 20

21 Deadlock Notions Formal Definition Formal Definition: A set of processes(klts) is deadlocked if each process(klt) in the set is waiting for an event that only another process(klt) in this set can cause! Usually the event processes are waiting for- is a release notification of a currently held resource or a v(semaphore) operation ending a critical section or????! None of the processes can! run! release resources or critical sections! be awakened (Why???) 2003 Universität Karlsruhe, System Architecture Group 21

22 Deadlock Notions Necessary Conditions for a Resource Deadlock 1. Exclusiveness No Sharing at all! a resource is either assigned to 1 process or is available 2. Hold and Wait Allocating/releasing occur at random! process holding resources can request additional resources 3. No Preemption from exclusive resources! previously granted resources cannot forcibly taken away 4. Circular Wait Circular dependency! must be a circular chain of at least 2 or more processes! each waiting for resource held by next member of chain Note: These are not sufficient conditions 2003 Universität Karlsruhe, System Architecture Group 22

23 Deadlock Notions Exclusiveness At least one resource must be held in a non-sharable mode, i.e. only a single thread (task) at a time can use this resource. If another thread (task) requests that resource, the requesting thread (task) must be delayed (e.g. blocked) until that resource is released Universität Karlsruhe, System Architecture Group 23

24 Deadlock Notions Hold and Wait There must exist a thread (task), that is holding at least one resource and that is waiting to acquire additional resources that are currently held by other threads (tasks) 2003 Universität Karlsruhe, System Architecture Group 24

25 Deadlock Notions No Preemption Resources cannot be preempted; a resource can be released only voluntarily by the thread (task) currently holding it Universität Karlsruhe, System Architecture Group 25

26 Deadlock Notions Circular Wait There must exist a closed chain of threads (tasks) {T 1,T 2, T k }, such that each thread T i holds at least one exclusive resource needed by T i+1, the next thread in this chain! 2003 Universität Karlsruhe, System Architecture Group 26

27 Deadlock Notions Resource Allocation Graph * Type R1 P holds R1 P P requests for one of the two objects of R2 Type R2 Remark: RAG = mean to illustrate deadlocks respectively situations without a deadlock * Peterson, Silberschatz 2003 Universität Karlsruhe, System Architecture Group 27

28 Deadlock Notions Circular Wait Condition R1 P1 requests R1 P2 holds R1 P1 P1 holds R2 P2 P2 requests R2 R2 The circular wait condition is sufficient for the existence of a deadlock iff only one object per resource type (one exemplar systems) 2003 Universität Karlsruhe, System Architecture Group 28

29 Deadlock Notions Specific Situations P R3 R1 Q R2 Question: Can a deadlock occur due to requests of threads P or Q? 2003 Universität Karlsruhe, System Architecture Group 29

30 Deadlock Notions Specific Situations P R3 R1 R2 Q P R3 Yes, if R2 is given to P, then an unsolvable circular wait exists. R1 Q R Universität Karlsruhe, System Architecture Group 30

31 Deadlock Notions Specific Situations R1 P Q R3 2xR2 T a deadlock due to circle in resource allocation graph? (Type R2 has 2 objects. One used by P, one by T) Not necessarily, you can run T, then Q, and finally P Universität Karlsruhe, System Architecture Group 31

32 Deadlock Notions Conditions for Deadlock 1. Exclusiveness 2. Hold and Wait Due to allocation policy 3. No Preemption 4. Circular Wait Snapshot of system behavior 2003 Universität Karlsruhe, System Architecture Group 32

33 Managing Deadlocks Managing Deadlocks! Prevention! Preventing deadlocks by constraining how requests for resources can be made in the system and how they are handled (system design)! Eliminate one of the four necessary deadlock conditions! Avoidance! System dynamically considers every request and decides whether it is safe to grant it at that time! Maximum requirements of each resource must be stated in advance by each process! Detection and Recovery! Ignoring 2003 Universität Karlsruhe, System Architecture Group 33

34 Deadlock Prevention Deadlock Prevention (1) Construct a system: deadlocks may never arise, i.e. ensure that at least one of the necessary conditions for deadlock won t occur Attacking the mutual-exclusion condition! Some physical and logical resources require mutually-exclusion, e.g. keyboard, stack etc.! We have to admit mutual exclusion! However, some resource types like Universität Karlsruhe, System Architecture Group 34

35 Deadlock Prevention Spooling a Resource! Some devices (see printer) can be spooled! only the printer daemon uses printer resource! thus deadlocks for spooled printer eliminated! Other devices (see CPU) can be virtualized! multiplexing the CPU is an elegant method 2003 Universität Karlsruhe, System Architecture Group 35

36 Deadlock Prevention Deadlock Prevention (2)! Attacking the hold-and-wait condition! Requires that each thread requests all resources by one single and atomic request. Consequence: Thread has to wait until all requests can be granted simultaneously.! Disadvantages:! Thread has to wait unnecessarily long until all resources are available, even though it may not use all resources in the next run! Resources allocated to a thread may remain unused for a long period. They could be used be other threads in the meantime.! An application must be aware of all resources that it will need eventually.! Impossibilities: e.g. a resource ping-pong between threads 2003 Universität Karlsruhe, System Architecture Group 36

37 Deadlock Prevention Deadlock Prevention (3)! Attacking the no-preemption condition! Preemption: once a resource request is denied, the according thread should release all resources that it already holds! Alternatively you could preempt the current resource owner to release its resources.! States of the preempted resources have to be saved for later resumption. Only possible when the state of a resource can be easily saved and restored! Enables live locks, even system-wide live locks (see dining philosophers) 2003 Universität Karlsruhe, System Architecture Group 37

38 Deadlock Prevention (3) Virtualization or Multiplexing of resources! no-preemption is a very condition? successful technique to avoid! Preemption: once deadlock a resource request problems. is denied, the according Processor, thread should memory, release files,... all resources are that obvious it already candidates, holds e.g., VMWARE multiplexes! Alternatively even you display could preempt and network the current hardware. resource owner to release its resources.! States of the preempted resources have to be saved for later resumption. Only possible when the state of a resource can be easily saved and restored! Enables live locks, even system-wide live locks (see dining philosophers) Deadlock Prevention 2003 Universität Karlsruhe, System Architecture Group 38

39 Deadlock Prevention Preemptive Printer?! This is not a viable option! Consider a process given the printer! halfway through its job! now forcibly take away printer!!!?? Hint: Try to find a solution for preempting even a printer, even though Andy won t like it 2003 Universität Karlsruhe, System Architecture Group 39

40 Deadlock Prevention Deadlock Prevention (4)! no-circular-wait condition! Define a strictly increasing linear ordering OR(RT) for resource types, e.g.! R1: tape drives: OR(R1) = 2! R2: disk drives: OR(R2) = 4! R3: printers: OR(R3) = 7! A thread initially requests a number of instances of a resource type, say Ri! A single request must be issued to obtain several instances.! After that, this thread can request instances for resource types Rj if and only if OR(Rj)>OR(Ri) 2003 Universität Karlsruhe, System Architecture Group 40

41 Deadlock Prevention Summary: Deadlock Prevention In general, this principle is either far too restrictive (you may request resources in some predefined ordering, only) or the usage of the resources is far too low (allocating all resources at the start is quite wasteful) or too much overhead is involved (e.g. a preemption costs time and requires additional containers for saving and restoring the resource states) in many commercial system prevention is not used 2003 Universität Karlsruhe, System Architecture Group 41

42 Deadlock Prevention Other Issues Two Phase Locking:! Phase One! process tries to lock all records it needs, one at a time! if needed record found locked, start over! (no real work done in phase one)! If phase one succeeds, it starts second phase,! performing updates! releasing locks! Note similarity to requesting all resources at once! Algorithm works where programmer can arrange! program can be stopped, restarted 2003 Universität Karlsruhe, System Architecture Group 42

43 Deadlock Prevention Non Resource Deadlocks! Possible for two processes to deadlock! each is waiting for the other to do some task! Can happen with semaphores! each process required to do a down() on two semaphores (mutex and another)! if done in wrong order, deadlock results 2003 Universität Karlsruhe, System Architecture Group 43

44 Deadlock Prevention Starvation! Algorithm to allocate a resource! may be to give to shortest job first! Works great for multiple short jobs in a system! May cause long jobs to be postponed indefinitely! even though not blocked! Solution:! First-come, first-serve policy 2003 Universität Karlsruhe, System Architecture Group 44

45 Deadlock Avoidance Deadlock Avoidance (1) At runtime a decision is made whether a complete new thread or a new request of an active thread might lead to a deadlock 2 straightforward policies:! Do not start a new thread if its requests all together with those of the current active threads might lead to a deadlock! Do not grant an incremented request to a thread if its allocation might lead to a deadlock 2003 Universität Karlsruhe, System Architecture Group 45

46 Deadlock Avoidance Deadlock Avoidance (1) Some formal description of the system Given: n threads T 1, T 2, T n and m resource types R 1, R 2, R m R = (r 1, r 2, r m ) total amount of each resource V = (v 1, v 2, v m ) total amount of each resource currently not allocated to one of the n threads 2003 Universität Karlsruhe, System Architecture Group 46

47 Deadlock Avoidance Deadlock Avoidance (3) C = C C. C n1 C C. C n C C C 1m 2m. nm Maximal requirement per resource of each thread A = A A. A n1 A A. A n A A A 1m 2m. nm Currently allocated resources of each thread 2003 Universität Karlsruhe, System Architecture Group 47

48 Deadlock Avoidance Invariants and Constraints R i = V i + n Aki k = 1 for all i: All resources are either available or allocated C ki Ri, for all k, i : no thread claims more than the total amount of resources in the system A k,i, k, Ck, i for all i : no thread is allocated more resources than initially claimed 2003 Universität Karlsruhe, System Architecture Group 48

49 Deadlock Avoidance Deadlock Avoidance Algorithm (1) Start a new thread iff ( if and only if) R i C n + 1, i + n k = 1 C ki for all i Policy is far too pessimistic assuming that all threads will request all their claimed resources at the same time. In practice, however, the following often holds:! Some of the claimed resources are never requested! Few threads need all their claimed resources at the same time we need a better, i.e. more optimistic algorithm 2003 Universität Karlsruhe, System Architecture Group 49

50 Deadlock Avoidance progress of thread 2 Release R1 Release R2 Smart passage Allocate R1 Allocate R2 Allocate R1 Allocate R2 Release R1 Release R2 progress of thread Universität Karlsruhe, System Architecture Group 50

51 Release R1 progress of thread 2 Titanic crash Deadlock Avoidance Deadlock Region Release R2 Allocate R1 Allocate R2 Is this a region we should avoid? Allocate R1 Allocate R2 Release R1 Release R1 progress of thread Universität Karlsruhe, System Architecture Group 51

52 progress of thread 2 Deadlock Avoidance Entering an unsafe region potential deadlock Release R1 Release R2 Deadlock Allocate R1 Allocate R2 Unsafe Region Allocate R1 Allocate R2 Release R1 Release R1 progress of thread Universität Karlsruhe, System Architecture Group 52

53 Deadlock Avoidance progress of thread 2 Entering unsafe region no deadlock this time Release R1 Release R2 Allocate R1 Allocate R2 unsafe region Allocate R1 Release R1 Allocate R2 Release R1 progress of thread Universität Karlsruhe, System Architecture Group 53

54 Deadlock Avoidance Safe State Definition: The state of a system of n threads is safe if there is at least one execution sequence allowing that all n threads can complete. More formally: System state = safe permutation <T k1,t k2, T kn > within {T 1, T 2,,T n } : for all i {1,2, n}: or for all i {1,2, n}: C C k k i i A A k k i i V R i + = s n 1 1 s= i A A k k s s 2003 Universität Karlsruhe, System Architecture Group 54

55 Deadlock Avoidance Banker Algorithm type state = record R,V: array[0..m-1] of integer C,A: array[o,n-1,0 m-1]of integer T: {set of threads} end procedure deadlock_avoidance (var answer:state, DT:set of threads) { answer := undefined /* initialization */ DT := T /* all threads deadlocked */ while answer = undefined do if T[i] DT: C[i] - A[i] V then { DT := DT \ {T[i]} V := V + A[i] if DT = {} then answer := safe } else answer := unsafe /* n 1 thread deadlocked */ od } O(n 2 m) with n = # of threads and m = # of resource types 2003 Universität Karlsruhe, System Architecture Group 55

56 Deadlock Detection Deadlock Detection If neither prevention nor avoidance works, at least you want to detect deadlocks. The whole concept is a bit more optimistic. Algorithm: Replace in the Banker Algorithm the if condition as follows: if T[i] DT: CR[i] V then... Remark: CR[1..n,1..m] is the matrix of the current pending requests! If there is a deadlock, DT = { deadlocked threads } 2003 Universität Karlsruhe, System Architecture Group 56

57 Deadlock Detection Deadlock Detection with 1 Resource of Each Type (a) Note the resource ownership and requests (b) Cycle found within the graph deadlock 2003 Universität Karlsruhe, System Architecture Group 57

58 Deadlock Detection Usage of Detection Algorithm! When and how often to invoke?! In the extreme case every time a request for a resource cannot be granted immediately! This comes with enormous cost /think about complexity in real systems)! Reasonable alternative periodically. But what period to use?! How long are we willing to wait after it happens to be detected! How much system resources are we willing to commit to this detection algorithm 2003 Universität Karlsruhe, System Architecture Group 58

59 Deadlock Recovery Recovery from Deadlock What can a system do after it has detected a deadlock?! Process termination! Abort all deadlocked processes:! That s fast, but..! A lot of work has been wasted! Abort one deadlocked process at a time and check for deadlock again! More work to resolve a deadlock! Better in terms of process work! But in which order to abort the processes?! Resource preemption! What is a good way to select a victim to be aborted! How can we rollback and recover from preemption! How can we protect from starvation 2003 Universität Karlsruhe, System Architecture Group 59

60 Deadlock Recovery Deadlock Recovery (1)! Recovery through preemption! take a resource from some other process! depends on nature of the resource! Recovery through rollback! checkpoint a process periodically! use this saved state! restart the process if it is found deadlocked 2003 Universität Karlsruhe, System Architecture Group 60

61 Deadlock Recovery Recovery (2)! Recovery through killing processes! crudest but simplest way to break a deadlock! kill one of the processes in the deadlock cycle! the other processes get its resources! choose process that can be rerun from the beginning 2003 Universität Karlsruhe, System Architecture Group 61

62 Deadlock Recovery Deadlock Recovery (3) What possibilities for killing processes?! Some criteria for aborting processes:! Size of pending request! Amount of allocated resources! Priority! Application-/system-process! Expected duration of abortion! Accumulated execution time! Expected remaining execution time!... If short, let it finish, if long, abort it 2003 Universität Karlsruhe, System Architecture Group 62

63 Ostrich Algorithm Ignoring Deadlocks Ostrich Algorithm :! Pretend there is no deadlock problem at all! Reasonable if! deadlocks occur very rarely! cost of prevention or avoidance is too high! UNIX and Windows takes this approach! It is a trade off between! convenience! correctness 2003 Universität Karlsruhe, System Architecture Group 63

64 Deadlock Management Combined Deadlock Policy We can combine some previous approaches in the following way: Group resources into a number of different classes and order them, e.g.: Swappable space (secondary memory) Task resources (I/O devices, files...) Main memory... Use prevention of circular wait to prevent deadlock between these resource classes Use the most appropriate approach against deadlocks within each class 2003 Universität Karlsruhe, System Architecture Group 64

Resource Management Deadlock Conditions Dealing with potential Deadlocks. January Winter Term 2008/09 Gerd Liefländer

Resource Management Deadlock Conditions Dealing with potential Deadlocks. January Winter Term 2008/09 Gerd Liefländer System Architecture 12 Deadlocks Resource Management Deadlock Conditions Dealing with potential Deadlocks January 7 2009 Winter Term 2008/09 Gerd Liefländer 2009 Universität Karlsruhe (TH), System Architecture

More information

Chapter 3. Deadlocks

Chapter 3. Deadlocks Chapter 3 Deadlocks 3.1 Resource 3.2 Introduction to deadlocks 3.3 The ostrich algorithm 3.4 Deadlock detection and recovery 3.5 Deadlock avoidance 3.6 Deadlock prevention 3.7 Other issues Resources Examples

More information

Resources. Lecture 4. Deadlocks. Resources (2) Resources (1) Four Conditions for Deadlock. Introduction to Deadlocks

Resources. Lecture 4. Deadlocks. Resources (2) Resources (1) Four Conditions for Deadlock. Introduction to Deadlocks Lecture 4 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks 3.3. The ostrich algorithm 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance 3.6. Deadlock prevention 3.7. Other issues Resources

More information

Chapter 3. Deadlocks

Chapter 3. Deadlocks Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks 3.3. The ostrich algorithm 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance 3.6. Deadlock prevention 3.7. Other issues Resources

More information

DEADLOCKS M O D E R N O P E R A T I N G S Y S T E M S C H A P T E R 6 S P R I N G

DEADLOCKS M O D E R N O P E R A T I N G S Y S T E M S C H A P T E R 6 S P R I N G DEADLOCKS M O D E R N O P E R A T I N G S Y S T E M S C H A P T E R 6 S P R I N G 2 0 1 8 NON-RESOURCE DEADLOCKS Possible for two processes to deadlock each is waiting for the other to do some task Can

More information

Deadlocks Prof. James L. Frankel Harvard University. Version of 7:05 PM 7-Mar-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved.

Deadlocks Prof. James L. Frankel Harvard University. Version of 7:05 PM 7-Mar-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved. Deadlocks Prof. James L. Frankel Harvard University Version of 7:05 PM 7-Mar-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved. Introduction to Deadlocks Computer resources Files Database

More information

Chapter 3: Deadlocks

Chapter 3: Deadlocks Chapter 3: Deadlocks Overview Resources Why do deadlocks occur? Dealing with deadlocks Ignoring them: ostrich algorithm Detecting & recovering from deadlock Avoiding deadlock Preventing deadlock Resources

More information

CS450/550 Operating Systems

CS450/550 Operating Systems CS450/550 Operating Systems Lecture 3 Deadlocks Dr. Xiaobo Zhou Department of Computer Science CS450/550 Deadlocks.1 Review: Summary of Chapter 2 Sequential process model Multi-threading: user-space vs.

More information

Chapter 6. Deadlocks

Chapter 6. Deadlocks Chapter 6 Deadlocks 6.. Resources 6.. Introduction to deadlocks 6.3. The ostrich algorithm 6.6. Deadlock prevention 6.4. Deadlock detection and recovery 6.5. Deadlock avoidance 6.7. Other issues Learning

More information

Deadlocks. Thomas Plagemann. With slides from C. Griwodz, K. Li, A. Tanenbaum and M. van Steen

Deadlocks. Thomas Plagemann. With slides from C. Griwodz, K. Li, A. Tanenbaum and M. van Steen Deadlocks Thomas Plagemann With slides from C. Griwodz, K. Li, A. Tanenbaum and M. van Steen Preempting Scheduler Activations Scheduler activations are completely preemptable User" space" Kernel " space"

More information

Deadlocks. Today. Next Time. ! Resources & deadlocks! Dealing with deadlocks! Other issues. ! Memory management

Deadlocks. Today. Next Time. ! Resources & deadlocks! Dealing with deadlocks! Other issues. ! Memory management Deadlocks Today! Resources & deadlocks! Dealing with deadlocks! Other issues Next Time! Memory management Introduction to deadlocks A set of threads is deadlocked if each thread in the set is waiting for

More information

Deadlocks. Today. Next Time. Resources & deadlocks Dealing with deadlocks Other issues. I/O and file systems

Deadlocks. Today. Next Time. Resources & deadlocks Dealing with deadlocks Other issues. I/O and file systems Deadlocks Today Resources & deadlocks Dealing with deadlocks Other issues Next Time I/O and file systems That s some catch, that Catch-22 Thread A: lock(l1); lock(l2);... A Thread B: lock(l2); lock(l1);...

More information

Operating Systems. Lecture3.2 - Deadlock Management. Golestan University. Hossein Momeni

Operating Systems. Lecture3.2 - Deadlock Management. Golestan University. Hossein Momeni Operating Systems Lecture3.2 - Deadlock Management Golestan University Hossein Momeni momeni@iust.ac.ir Contents Resources Introduction to deadlocks Why do deadlocks occur? Ignoring deadlocks : ostrich

More information

Learning Outcomes. Chapter 3. Deadlocks. Resources. Resources. Resources

Learning Outcomes. Chapter 3. Deadlocks. Resources. Resources. Resources hapter Deadlocks.. esource.. Introduction to deadlocks.. The ostrich algorithm.4. Deadlock detection and recovery.5. Deadlock avoidance.6. Deadlock prevention.7. Other issues Learning Outcomes Understand

More information

Resources. Chapter 3. Deadlocks. Resources. Resources

Resources. Chapter 3. Deadlocks. Resources. Resources hapter Deadlocks.. esource.. Introduction to deadlocks.. The ostrich algorithm.4. Deadlock detection and recovery.5. Deadlock avoidance.6. Deadlock prevention.7. Other issues esources Examples of computer

More information

Deadlocks. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Deadlocks. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Deadlocks Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics What is the deadlock problem? Four conditions for deadlock Handling deadlock

More information

Learning Outcomes. Chapter 6. Deadlocks. Resources. Resources & Deadlocks. Resource Access. Two example resource usage patterns

Learning Outcomes. Chapter 6. Deadlocks. Resources. Resources & Deadlocks. Resource Access. Two example resource usage patterns hapter 6 Deadlocks 6.. esources 6.. Introduction to deadlocks 6.. The ostrich algorithm 6.6. Deadlock prevention 6.4. Deadlock detection and recovery 6.5. Deadlock avoidance 6.7. Other issues Learning

More information

OPERATING SYSTEMS. Deadlocks

OPERATING SYSTEMS. Deadlocks OPERATING SYSTEMS CS3502 Spring 2018 Deadlocks Chapter 7 Resource Allocation and Deallocation When a process needs resources, it will normally follow the sequence: 1. Request a number of instances of one

More information

OPERATING SYSTEMS. Prescribed Text Book. Operating System Principles, Seventh Edition. Abraham Silberschatz, Peter Baer Galvin and Greg Gagne

OPERATING SYSTEMS. Prescribed Text Book. Operating System Principles, Seventh Edition. Abraham Silberschatz, Peter Baer Galvin and Greg Gagne OPERATING SYSTEMS Prescribed Text Book Operating System Principles, Seventh Edition By Abraham Silberschatz, Peter Baer Galvin and Greg Gagne 1 DEADLOCKS In a multi programming environment, several processes

More information

More on Synchronization and Deadlock

More on Synchronization and Deadlock Examples of OS Kernel Synchronization More on Synchronization and Deadlock Two processes making system calls to read/write on the same file, leading to possible race condition on the file system data structures

More information

The Slide does not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams.

The Slide does not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams. The Slide does not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams. System Model Deadlock Characterization Methods of handling

More information

Deadlocks. Tore Larsen. With slides from T. Plagemann, C. Griwodz, K. Li, A. Tanenbaum and M. van Steen

Deadlocks. Tore Larsen. With slides from T. Plagemann, C. Griwodz, K. Li, A. Tanenbaum and M. van Steen Deadlocks Tore Larsen With slides from T. Plagemann,. Griwodz, K. Li, A. Tanenbaum and M. van Steen Resources Resource allocation is a central OS concern Examples of computer resources PU Memory Disk drive

More information

Shared and Preemptable Resources. A few resources may be sharable. Anyone can write the system log.

Shared and Preemptable Resources. A few resources may be sharable. Anyone can write the system log. Shared and Preemptable Resources A few resources may be sharable Anyone can write the system log Deadlock Ch 3 Some resources are preemptable They can be safely taken away Memory may be preempted by swapping

More information

! What is a deadlock? ! What causes a deadlock? ! How do you deal with (potential) deadlocks? Maria Hybinette, UGA

! What is a deadlock? ! What causes a deadlock? ! How do you deal with (potential) deadlocks? Maria Hybinette, UGA Chapter 8: Deadlock Questions? CSCI 4730 Operating Systems! What is a deadlock?! What causes a deadlock?! How do you deal with (potential) deadlocks? Deadlock Deadlock: What is a deadlock? Example: Two

More information

The Deadlock Problem (1)

The Deadlock Problem (1) Deadlocks The Deadlock Problem (1) A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set. Example System has 2 disk drives. P 1 and P 2

More information

Deadlock. A Bit More on Synchronization. The Deadlock Problem. Deadlock Characterization. Operating Systems 2/7/2005. CSC 256/456 - Spring

Deadlock. A Bit More on Synchronization. The Deadlock Problem. Deadlock Characterization. Operating Systems 2/7/2005. CSC 256/456 - Spring A Bit More on Synchronization Deadlock CS 256/456 Dept. of Computer Science, University of Rochester Synchronizing interrupt handlers: Interrupt handlers run at highest priority and they must not block.

More information

Introduction to OS. Deadlock. MOS Ch. 6. Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

Introduction to OS. Deadlock. MOS Ch. 6. Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1 Introduction to OS Deadlock MOS Ch. 6 Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Introduction to OS 1 Outline What is Deadlock? How to handle Deadlock? Deadlock Detection and Recovery

More information

Deadlock and Starvation

Deadlock and Starvation Deadlock and Starvation Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate with each other Involve conflicting needs for resources by two or more

More information

Deadlocks. Copyright : University of Illinois CS 241 Staff 1

Deadlocks. Copyright : University of Illinois CS 241 Staff 1 Deadlocks 1 Deadlock Which way should I go? 2 Deadlock I Oh can no! almost I m get stuck! across GRIDLOCK! 3 Deadlock Definition Deadlocked process Waiting for an event that will never occur Typically,

More information

Deadlock and Starvation

Deadlock and Starvation Deadlock and Starvation Deadlock Permanent blocking of a set of processes Processes are waiting on events, but the events can only be triggered by other blocked processes No simple, efficient solution

More information

Chapter 7: Deadlocks. Operating System Concepts 8th Edition, modified by Stewart Weiss

Chapter 7: Deadlocks. Operating System Concepts 8th Edition, modified by Stewart Weiss Chapter 7: Deadlocks, Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance (briefly) Deadlock Detection

More information

VI. Deadlocks. What is a Deadlock? Intended Schedule. Deadlock Problem (1) ???

VI. Deadlocks. What is a Deadlock? Intended Schedule. Deadlock Problem (1) ??? Intended Schedule VI. Deadlocks Date Lecture Hand out Submission 0 20.04. Introduction to Operating Systems Course registration 1 27.04. Systems Programming using C (File Subsystem) 1. Assignment 2 04.05.

More information

VI. Deadlocks Operating Systems Prof. Dr. Marc H. Scholl DBIS U KN Summer Term

VI. Deadlocks Operating Systems Prof. Dr. Marc H. Scholl DBIS U KN Summer Term VI. Deadlocks 1 Intended Schedule Date Lecture Hand out Submission 0 20.04. Introduction to Operating Systems Course registration 1 27.04. Systems Programming using C (File Subsystem) 1. Assignment 2 04.05.

More information

CSE120 Principles of Operating Systems. Prof Yuanyuan (YY) Zhou Deadlock

CSE120 Principles of Operating Systems. Prof Yuanyuan (YY) Zhou Deadlock CSE120 Principles of Operating Systems Prof Yuanyuan (YY) Zhou Using Semaphore to Share Resource 2 3 4 5 Process P(); { A.Down(); B.Down(); 0 6 use both resource B.Up(); A.Up(); } Process Q(); { A.Down();

More information

System Model. Types of resources Reusable Resources Consumable Resources

System Model. Types of resources Reusable Resources Consumable Resources Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock System Model Types

More information

!! What is a deadlock? !! What causes a deadlock? !! How do you deal with (potential) deadlocks? Maria Hybinette, UGA

!! What is a deadlock? !! What causes a deadlock? !! How do you deal with (potential) deadlocks? Maria Hybinette, UGA Chapter 8: Deadlock Questions? CSCI [4 6]730 Operating Systems!! What is a deadlock?!! What causes a deadlock?!! How do you deal with (potential) deadlocks? Deadlock 2 Deadlock: What is a deadlock? Example:

More information

Operating Systems ECE344. Ding Yuan

Operating Systems ECE344. Ding Yuan Operating Systems ECE344 Ding Yuan Deadlock Synchronization is a live gun we can easily shoot ourselves in the foot Incorrect use of synchronization can block all processes We have talked about this problem

More information

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition,

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition, Chapter 7: Deadlocks, Silberschatz, Galvin and Gagne 2009 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks To present a number

More information

Deadlocks. Operating System Concepts - 7 th Edition, Feb 14, 2005

Deadlocks. Operating System Concepts - 7 th Edition, Feb 14, 2005 Deadlocks Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock 7.2 Silberschatz,

More information

Chapter 3: Deadlocks. Chapter 3

Chapter 3: Deadlocks. Chapter 3 hapter 3: Deadlocks hapter 3 Overview Resources Why do deadlocks occur? Dealing with deadlocks Ignoring them: ostrich algorithm Detecting & recovering from deadlock voiding deadlock Preventing deadlock

More information

Deadlocks. Dr. Yingwu Zhu

Deadlocks. Dr. Yingwu Zhu Deadlocks Dr. Yingwu Zhu Deadlocks Synchronization is a live gun we can easily shoot ourselves in the foot Incorrect use of synchronization can block all processes You have likely been intuitively avoiding

More information

Operating Systems. Deadlock. User OS. Kernel & Device Drivers. Interface Programs. Brian Mitchell - Operating Systems

Operating Systems. Deadlock. User OS. Kernel & Device Drivers. Interface Programs. Brian Mitchell - Operating Systems User OS Kernel & Device Drivers Interface Programs Deadlock 1 Deadlocks Computer resources are full of resources that can only be used by one process at a time Unpredictable results can occur if two or

More information

CS420: Operating Systems. Deadlocks & Deadlock Prevention

CS420: Operating Systems. Deadlocks & Deadlock Prevention Deadlocks & Deadlock Prevention James Moscola Department of Physical Sciences York College of Pennsylvania Based on Operating System Concepts, 9th Edition by Silberschatz, Galvin, Gagne The Deadlock Problem

More information

Chapter 6 Concurrency: Deadlock and Starvation

Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles Chapter 6 Concurrency: Deadlock and Starvation Seventh Edition By William Stallings Edited by Rana Forsati CSE410 Outline Principles of deadlock Deadlock

More information

Deadlock 1 Chapter 6

Deadlock 1 Chapter 6 Deadlock 1 Chapter 6 2 Deadlock A set of processes is deadlocked when each process in the set is blocked awaiting an event that can only be triggered by another blocked process in the set Permanent blocking

More information

COMPUTER SCIENCE 4500 OPERATING SYSTEMS

COMPUTER SCIENCE 4500 OPERATING SYSTEMS Last update: 2/23/2017 COMPUTER SCIENCE 4500 OPERATING SYSTEMS 2017 Stanley Wileman Module 7: Deadlocks In This Module 2! Deadlock: Definition and Examples! Deadlock: Models! Deadlock: Prevention Algorithms

More information

Last Class: Monitors. Real-world Examples

Last Class: Monitors. Real-world Examples Last Class: Monitors Monitor wraps operations with a mutex Condition variables release mutex temporarily C++ does not provide a monitor construct, but monitors can be implemented by following the monitor

More information

Computer Science 4500 Operating Systems. In This Module. Deadlock Definition. Module 7 Deadlocks

Computer Science 4500 Operating Systems. In This Module. Deadlock Definition. Module 7 Deadlocks Computer Science 4500 Operating Systems Module 7 Deadlocks 2008 Stanley A. Wileman, Jr. Operating Systems Slide 1 In This Module Deadlock: Definition and Examples Deadlock: Models Deadlock: Prevention

More information

Computer Science 4500 Operating Systems

Computer Science 4500 Operating Systems Computer Science 4500 Operating Systems Module 7 Deadlocks 2008 Stanley A. Wileman, Jr. Operating Systems Slide 1 1 In This Module Deadlock: Definition and Examples Deadlock: Models Deadlock: Prevention

More information

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition,! Silberschatz, Galvin and Gagne 2009!

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition,! Silberschatz, Galvin and Gagne 2009! Chapter 7: Deadlocks Operating System Concepts 8 th Edition,! Silberschatz, Galvin and Gagne 2009! Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling

More information

Bridge Crossing Example

Bridge Crossing Example CSCI 4401 Principles of Operating Systems I Deadlocks Vassil Roussev vassil@cs.uno.edu Bridge Crossing Example 2 Traffic only in one direction. Each section of a bridge can be viewed as a resource. If

More information

Chapter 8: Deadlocks. The Deadlock Problem

Chapter 8: Deadlocks. The Deadlock Problem Chapter 8: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Combined Approach to Deadlock

More information

The Deadlock Problem. Chapter 8: Deadlocks. Bridge Crossing Example. System Model. Deadlock Characterization. Resource-Allocation Graph

The Deadlock Problem. Chapter 8: Deadlocks. Bridge Crossing Example. System Model. Deadlock Characterization. Resource-Allocation Graph Chapter 8: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Combined

More information

Deadlock. Concurrency: Deadlock and Starvation. Reusable Resources

Deadlock. Concurrency: Deadlock and Starvation. Reusable Resources Concurrency: Deadlock and Starvation Chapter 6 Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate with each other No efficient solution Involve conflicting

More information

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition,

Chapter 7: Deadlocks. Operating System Concepts 8 th Edition, Chapter 7: Deadlocks, Silberschatz, Galvin and Gagne 2009 Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance

More information

Process Management. Deadlock. Process Synchronization. Management Management. Starvation

Process Management. Deadlock. Process Synchronization. Management Management. Starvation Process Management Deadlock 7 Cases of Deadlock Conditions for Deadlock Modeling Deadlocks Strategies for Handling Deadlocks Avoidance Detection Recovery Starvation Process Synchronization Deadlock Starvation

More information

MODERN OPERATING SYSTEMS. Third Edition ANDREW S. TANENBAUM. Chapter 6 Deadlocks

MODERN OPERATING SYSTEMS. Third Edition ANDREW S. TANENBAUM. Chapter 6 Deadlocks MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Preemptable and Nonpreemptable Resources Non-sharable resource: the resource can be used by only one process at a time A process

More information

Lecture 7 Deadlocks (chapter 7)

Lecture 7 Deadlocks (chapter 7) Bilkent University Department of Computer Engineering CS342 Operating Systems Lecture 7 Deadlocks (chapter 7) Dr. İbrahim Körpeoğlu http://www.cs.bilkent.edu.tr/~korpe 1 References The slides here are

More information

Deadlock 1 Chapter 6

Deadlock 1 Chapter 6 Deadlock 1 Chapter 6 2 Deadlock A set of processes is deadlocked when each process in the set is blocked awaiting an event that can only be triggered by another blocked process in the set Permanent blocking

More information

Deadlock. Concepts to discuss. A System Model. Deadlock Characterization. Deadlock: Dining-Philosophers Example. Deadlock: Bridge Crossing Example

Deadlock. Concepts to discuss. A System Model. Deadlock Characterization. Deadlock: Dining-Philosophers Example. Deadlock: Bridge Crossing Example Concepts to discuss Deadlock CSCI 315 Operating Systems Design Department of Computer Science Deadlock Livelock Spinlock vs. Blocking Notice: The slides for this lecture have been largely based on those

More information

Chapter 7: Deadlocks

Chapter 7: Deadlocks Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Chapter

More information

UNIT 4 DEADLOCKS 4.0 INTRODUCTION

UNIT 4 DEADLOCKS 4.0 INTRODUCTION UNIT 4 DEADLOCKS Deadlocks Structure Page Nos 4.0 Introduction 69 4.1 Objectives 70 4.2 Deadlocks 70 4.3 Characterisation of a Deadlock 71 4.3.1 Mutual Exclusion Condition 4.3.2 Hold and Wait Condition

More information

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.

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. Deadlock 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 semaphores A and B, initialized to 1 P 0 P

More information

Chapter 7: Deadlocks. Operating System Concepts with Java 8 th Edition

Chapter 7: Deadlocks. Operating System Concepts with Java 8 th Edition Chapter 7: Deadlocks 7.1 Silberschatz, Galvin and Gagne 2009 Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock

More information

Chapter 7: Deadlocks

Chapter 7: Deadlocks Chapter 7: Deadlocks Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from

More information

The Deadlock Problem

The Deadlock Problem 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 System has 2 disk drives. P 1 and P 2 each hold one

More information

Concurrency problems. To do. q Non-deadlock bugs q Resources & deadlocks q Dealing with deadlocks q Other issues q Next Time: I/O and file systems

Concurrency problems. To do. q Non-deadlock bugs q Resources & deadlocks q Dealing with deadlocks q Other issues q Next Time: I/O and file systems Concurrency problems To do q Non-deadlock bugs q Resources & deadlocks q Dealing with deadlocks q Other issues q Next Time: I/O and file systems Bugs in some modern applications From some key apps, a summary

More information

Chapter 7: Deadlocks

Chapter 7: Deadlocks Chapter 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Combined Approach to Deadlock

More information

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition Chapter 7: Deadlocks Silberschatz, Galvin and Gagne 2013 Chapter 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection

More information

COP 4610: Introduction to Operating Systems (Spring 2016) Chapter 7 Deadlocks. Zhi Wang Florida State University

COP 4610: Introduction to Operating Systems (Spring 2016) Chapter 7 Deadlocks. Zhi Wang Florida State University COP 4610: Introduction to Operating Systems (Spring 2016) Chapter 7 Deadlocks Zhi Wang Florida State University Contents Deadlock problem System model Handling deadlocks deadlock prevention deadlock avoidance

More information

Chapter 7 : 7: Deadlocks Silberschatz, Galvin and Gagne 2009 Operating System Concepts 8th Edition, Chapter 7: Deadlocks

Chapter 7 : 7: Deadlocks Silberschatz, Galvin and Gagne 2009 Operating System Concepts 8th Edition, Chapter 7: Deadlocks Chapter 7: Deadlocks, Silberschatz, Galvin and Gagne 2009 Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance

More information

Chapter 7: Deadlocks. Chapter 7: Deadlocks. The Deadlock Problem. Chapter Objectives. System Model. Bridge Crossing Example

Chapter 7: Deadlocks. Chapter 7: Deadlocks. The Deadlock Problem. Chapter Objectives. System Model. Bridge Crossing Example Silberschatz, Galvin and Gagne 2009 Chapter 7: Deadlocks Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance

More information

UNIT:2. Process Management

UNIT:2. Process Management 1 UNIT:2 Process Management SYLLABUS 2.1 Process and Process management i. Process model overview ii. Programmers view of process iii. Process states 2.2 Process and Processor Scheduling i Scheduling Criteria

More information

Chapter 8: Deadlocks

Chapter 8: Deadlocks Chapter 8: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Combined Approach to Deadlock

More information

Chapter 8: Deadlocks. The Deadlock Problem. System Model. Bridge Crossing Example. Resource-Allocation Graph. Deadlock Characterization

Chapter 8: Deadlocks. The Deadlock Problem. System Model. Bridge Crossing Example. Resource-Allocation Graph. Deadlock Characterization Chapter 8: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Combined

More information

CISC 7310X. C10: Deadlocks. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 4/12/2018 CUNY Brooklyn College

CISC 7310X. C10: Deadlocks. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 4/12/2018 CUNY Brooklyn College CISC 7310X C10: Deadlocks Hui Chen Department of Computer & Information Science CUNY Brooklyn College 4/12/2018 CUNY Brooklyn College 1 Outline Concept of deadlock Necessary conditions Models of deadlocks

More information

Module 7: Deadlocks. The Deadlock Problem

Module 7: Deadlocks. The Deadlock Problem Module 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Combined Approach to Deadlock

More information

Module 7: Deadlocks. System Model. Deadlock Characterization. Methods for Handling Deadlocks. Deadlock Prevention. Deadlock Avoidance

Module 7: Deadlocks. System Model. Deadlock Characterization. Methods for Handling Deadlocks. Deadlock Prevention. Deadlock Avoidance Module 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Combined Approach to Deadlock

More information

Chapter 8: Deadlocks. The Deadlock Problem

Chapter 8: Deadlocks. The Deadlock Problem Chapter 8: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Combined Approach to Deadlock

More information

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem? What is the Race Condition? And what is its solution? Race Condition: Where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular

More information

Chapter 7: Deadlocks 1

Chapter 7: Deadlocks 1 1 Reminders: February 24, 2014 I hope you had a good Reading Week! Exercise 3 is due this Wednesday Any questions about anything? Don t forget about Assignment 2, due next week 2 Comments on Exercise 2

More information

Module 7: Deadlocks. The Deadlock Problem. Bridge Crossing Example. System Model

Module 7: Deadlocks. The Deadlock Problem. Bridge Crossing Example. System Model Module 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Combined

More information

Concurrency: Deadlock and Starvation. Chapter 6

Concurrency: Deadlock and Starvation. Chapter 6 Concurrency: Deadlock and Starvation Chapter 6 1 What is Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate with each other Involve conflicting needs

More information

The Deadlock Problem

The Deadlock Problem Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock The Deadlock

More information

Chapter 7: Deadlocks

Chapter 7: Deadlocks Chapter 7: Deadlocks Chapter 7: Deadlocks 7.1 System Model 7.2 Deadlock Characterization 7.3 Methods for Handling Deadlocks 7.4 Deadlock Prevention 7.5 Deadlock Avoidance 7.6 Deadlock Detection 7.7 Recovery

More information

Concurrency: Deadlock and Starvation. Chapter 6

Concurrency: Deadlock and Starvation. Chapter 6 Concurrency: Deadlock and Starvation Chapter 6 Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate with each other Involve conflicting needs for resources

More information

Deadlocks. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University.

Deadlocks. Minsoo Ryu. Real-Time Computing and Communications Lab. Hanyang University. Deadlocks Minsoo Ryu Real-Time Computing and Communications Lab. Hanyang University msryu@hanyang.ac.kr Topics Covered System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention

More information

Contents. Chapter 8 Deadlocks

Contents. Chapter 8 Deadlocks Contents * All rights reserved, Tei-Wei Kuo, National Taiwan University,.. Introduction. Computer-System Structures. Operating-System Structures 4. Processes 5. Threads 6. CPU Scheduling 7. Process Synchronization

More information

Deadlocks. Deadlock Overview

Deadlocks. Deadlock Overview Deadlocks Gordon College Stephen Brinton Deadlock Overview The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection

More information

System Model. Deadlocks. Deadlocks. For example: Semaphores. Four Conditions for Deadlock. Resource Allocation Graph

System Model. Deadlocks. Deadlocks. For example: Semaphores. Four Conditions for Deadlock. Resource Allocation Graph System Model Deadlocks There are non-shared computer resources Maybe more than one instance Printers, Semaphores, Tape drives, CPU Processes need access to these resources Acquire resource If resource

More information

Principles of Operating Systems

Principles of Operating Systems Principles of Operating Systems Lecture 11 - Deadlocks Ardalan Amiri Sani (ardalan@uci.edu) [lecture slides contains some content adapted from previous slides by Prof. Nalini Venkatasubramanian, and course

More information

CSCC 69H3 2/1/13. Today: Deadlock. Remember example from last week? Example of Deadlock. Example: dining philosophers: Not just an OS Problem!

CSCC 69H3 2/1/13. Today: Deadlock. Remember example from last week? Example of Deadlock. Example: dining philosophers: Not just an OS Problem! 2/1/13 Today: Deadlock CSCC 69H3 Operating Systems Winter 2013 Professor Bianca Schroeder U of T Remember example from last week? My_work(id_t id) { /* id can be 0 or 1 */ flag[id] = true; /* indicate

More information

Deadlock Risk Management

Deadlock Risk Management Lecture 5: Deadlocks, Deadlock Risk Management Contents The Concept of Deadlock Resource Allocation Graph Approaches to Handling Deadlocks Deadlock Avoidance Deadlock Detection Recovery from Deadlock AE3B33OSD

More information

Introduction to Deadlocks

Introduction to Deadlocks Unit 5 Introduction to Deadlocks Structure 5.1 Introduction Objectives 5.2 System Model 5.3 Deadlock Characterization Necessary Conditions for Deadlock Resource-Allocation Graph. 5.4 Deadlock Handling

More information

Deadlocks. Prepared By: Kaushik Vaghani

Deadlocks. Prepared By: Kaushik Vaghani Deadlocks Prepared By : Kaushik Vaghani Outline System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection & Recovery The Deadlock Problem

More information

CS307 Operating Systems Deadlocks

CS307 Operating Systems Deadlocks CS307 Deadlocks Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2016 Bridge Crossing Example Traffic only in one direction Each section of a bridge can be viewed

More information

Deadlocks. Bridge Crossing Example. The Problem of Deadlock. Deadlock Characterization. Resource-Allocation Graph. System Model

Deadlocks. Bridge Crossing Example. The Problem of Deadlock. Deadlock Characterization. Resource-Allocation Graph. System Model CS07 Bridge Crossing Example Deadlocks Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2016 Traffic only in one direction Each section of a bridge can be viewed

More information

What is Deadlock? Two or more entities need a resource to make progress, but will never get that resource. Examples from everyday life:

What is Deadlock? Two or more entities need a resource to make progress, but will never get that resource. Examples from everyday life: Chapter 10 Deadlock What is Deadlock? Two or more entities need a resource to make progress, but will never get that resource Examples from everyday life: Gridlock of cars in a city Class scheduling: Two

More information

Principles of Operating Systems

Principles of Operating Systems Principles of Operating Systems Lecture 16-17 - Deadlocks Ardalan Amiri Sani (ardalan@uci.edu) [lecture slides contains some content adapted from previous slides by Prof. Nalini Venkatasubramanian, and

More information

Deadlocks: Part I Prevention and Avoidance Yi Shi Fall 2017 Xi an Jiaotong University

Deadlocks: Part I Prevention and Avoidance Yi Shi Fall 2017 Xi an Jiaotong University Deadlocks: Part I Prevention and Avoidance Yi Shi Fall 2017 Xi an Jiaotong University Review: Motivation for Monitors and Condition Variables Semaphores are a huge step up, but: They are confusing because

More information