Deadlocks. Frédéric Haziza Spring Department of Computer Systems Uppsala University

Size: px
Start display at page:

Download "Deadlocks. Frédéric Haziza Spring Department of Computer Systems Uppsala University"

Transcription

1 Deadlocks Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008

2 Outline 1 Quick recall on Synchronisation 2 Characterizing Deadlocks 3 Handling Deadlocks 2 OSKomp 08 Deadlocks

3 Synchronisation Communication Synchronisation Synchronisation Mutual Exclusion Condition synchronisation Example (Mutual Exclusion) Whenever 2 processes need to take runs accessing shared objects Example (Condition synchronisation) Whenever one process needs to wait for another 4 OSKomp 08 Deadlocks

4 Atomicity Bank account example Balance b = 0 sek. Person A does a deposit of 100 sek. Person B does a deposit of 200 sek Balance should be 300 sek. A Balance b B 0 load R 4, b load R 2, b 0 add R 2,#100 store b, R add R 4,# store b, R 4 Solution: Synchronisation (Locks,Semaphores,Monitors,Retry loops,...) 5 OSKomp 08 Deadlocks

5 Atomicity Another example sum:=0 while (sum < N) while (sum < N) sum:=sum+1 while (sum < N) sum:=sum+1 while (sum < N) sum:=sum+1 sum:=sum+1 How many additions? Anything between N and N*4 6 OSKomp 08 Deadlocks print(sum) What is printed? Anything between N and N+3

6 Critical Section CO [Process i = 1 to n] { while (true) { LOCK(resource); } } Assumption Do critical section work; UNLOCK(resource); Do NON-critical section work; A process may only terminate in its NON-critical section 7 OSKomp 08 Deadlocks

7 The programmer s nightmare begins The programmer must implement correct synchronization! Example (lock S and Q) P 1 P 2 lock(s) lock(q) lock(q) lock(s) unlock(q) unlock(s) unlock(s) unlock(q) Leads to deadlock: Both P 1 and P 2 are waiting for each other Additionally, bad implementation can lead to starvation. 8 OSKomp 08 Deadlocks

8 Say stop at entry section... The main issue is How do we make a thread wait? A solution: Busy waiting Check repeatedly a condition until it becomes true. Another solution: Blocking Waiting threads are de-scheduled High overhead Allows processor to do other things Hybrid methods: Busy-wait a while, then block 9 OSKomp 08 Deadlocks

9 Challenge Task Design the LOCK and UNLOCK routines. Ensuring: Mutual Exclusion No deadlocks No unnecessary delays Eventual Entry 10 OSKomp 08 Deadlocks

10 Requirements for a solution Mutual exclusion Only one process at a time in its CS Progress If no process is in its CS and some processes want to enter their CS, only those processes which are not in their remainder section can influence the decision on which process will enter its CS next. This decision can not be postponed indefinitely Bounded waiting When one process has requested to enter its CS, there is a limit on the number of times other processes can enter their CS before the request is granted. 11 OSKomp 08 Deadlocks

11 How to? < await(!lock) and then lock = true; > Read-Modify-Write atomic primitives Test and Set (TAS): Value at Mem[lock_addr] loaded in a specified register. Constant 1 atomically stored into Mem[lock_addr] Swap: Atomically swaps the value of REG with Mem[lock_addr] Compare and Swap (CAS): Swaps if Mem[lock_addr]==REG2 Fetch and Add (FA): Increments a value by a given constant and returns the old value 12 OSKomp 08 Deadlocks

12 Spin Lock bool TAS(bool lock) { < bool initial = lock; Save the initial value lock = true; Set lock return initial; > Return initial value } lock(lock_variable) { while(tas(lock_variable)==true){}; } Bang on the lock until free unlock(lock_variable) { lock_variable:=false; } Reset to the initial value 13 OSKomp 08 Deadlocks

13 Test and Test and Set lock(lock_variable) { while(tas(lock_variable)==true){}; } } lock(lock_variable) { More optimistic solution while (true) { if(tas(lock_variable)==false) break; } Bang on the lock once while(lock_variable==true){}; 14 OSKomp 08 Deadlocks

14 Tie Breaker Petersson s algorithm Remember who had the lock latest! bool in1 = false, in2 = false; int last = 1; Process 1 while (true) { in1=true, last = 1; while(in2 and last==1){}; Do critical section work in1=false; Do NON-critical section work } Process 2 while (true) { in2=true, last = 2; while(in1 and last==2){}; Do critical section work in2=false; Do NON-critical section work } 15 OSKomp 08 Deadlocks

15 Ticket-based lock CO [Process i = 1 to n] { while (true) { <turn[i] = number; number = number+1;> < await(turn[i] == number);> Do critical section < next = next+1;> Do NON-critical section } } Fetch and Add (FA) Increments a value by a given constant and returns the old value CO [Process i = 1 to n] { while (true) { turn[i] = FA(number,1); while(turn[i]!= next){}; Do critical section next = next+1; Do NON-critical section } } Can even have a back-off 16 OSKomp 08 Deadlocks

16 Semaphore Shared variable with 2 atomic methods: } P(Semaphore s) { Probeer (try) / Passeren (pass) / Pakken (grab) < wait until c > 0, then c := c-1; > must be atomic once c > 0 is detected } V(Semaphore s) { Verhoog (increase) < c = c + 1; > must be atomic Init(Semaphore s, Integer i){ c := i; } 17 OSKomp 08 Deadlocks

17 Semaphores, what for? Critical section: Mutual exclusion Barriers: Signaling events Producers and Consumers Bounded buffers: Resource counting 18 OSKomp 08 Deadlocks

18 Critical section sem mutex; Init(sem,1); 1 0 while (true) { Process 1 } P(mutex); Critical section V(mutex); NON-Critical section while (true) { Process 2 } P(mutex); Critical section V(mutex); NON-Critical section 19 OSKomp 08 Deadlocks

19 Barriers: Signaling events sem arrive1, arrive2; Init(arrive1,0); Init(arrive2,0); 0 0 Barrier Section A Section B... process 1 in section A V(arrive1); signal arrival P(arrive2); Wait for the other process... process 1 in section B... process 2 in section A V(arrive2); signal arrival P(arrive1); Wait for the other process... process 2 in section B 20 OSKomp 08 Deadlocks

20 Semaphores: Procuders and Consumers put Empty Full 1 0 take Producer Consumer Buffer Split Binary Semaphore Both are binary semaphores 21 OSKomp 08 Deadlocks

21 Bounded buffer: Resource counting put Empty n Full 0 take Producer Consumer Buffer 22 OSKomp 08 Deadlocks

22 Semaphores, what for? Empty Full 1 0 n Critical Section Blocking semaphore Barriers/Signaling Split Binary semaphore Resource Counting 23 OSKomp 08 Deadlocks

23 Dining Philosophers Problem Philopher 1 Philopher 2 Spaghetti Philopher 0 Philopher 3 Philopher 4 sem fork[5] = {1,1,1,1,1} while (true) { Philosopher 0,1,2,3,4 think; P(fork[i]);P(fork[i+1]); eat; V(fork[i]);V(fork[i+1]); } 24 OSKomp 08 Deadlocks

24 Readers/Writers Shared Resource Readers Writer Writer Example of selective mutual exclusion Example of general condition synchronization 25 OSKomp 08 Deadlocks

25 Monitors Skip 26 OSKomp 08 Deadlocks

26 Outline 1 Quick recall on Synchronisation 2 Characterizing Deadlocks Resources Resource Allocation Graph Conditions 3 Handling Deadlocks 27 OSKomp 08 Deadlocks

27 Resources In shared memory systems, synchronisation deals with CPU allocation with respect to...memory! Other types of resources: CPU, disks, tapes, files,...memory. Each resource type may have a different number of instances (example: 2 CPUs, 3 disks, N buffer places...) but instances may or may not be equivalent (e.g. printers on different floors). 28 OSKomp 08 Deadlocks

28 Resources To protect against races, a resource may be 1 requested before use, waiting until it is available. Open file, allocate memory, move to ready queue... 2 used 3 released after use. Close file, deallocate memory, terminate/wait... Deadlock Arises when two or more processes wait for each other, and the only way out is if one releases a resource another is waiting for. 29 OSKomp 08 Deadlocks

29 Resource Allocation Graph A graph a set of vertices υ a set of edges ǫ System Resource Allocation Graph Active Processes P = {P 1, P 2,...,P n } (Circles) Resource Types R = {R 1, R 2,..., R m } (Boxes) Request edges (P i R j ) Assignment edges (R j P i ) Number of instances per resource type 30 OSKomp 08 Deadlocks

30 Deadlocks: Resource Allocation Graph R 1 R 3 P 1 P 2 P 3 Deadlock? No cycle No process is deadlocked If cycle, deadlock may exist R 2 R 4 31 OSKomp 08 Deadlocks

31 Cycle in the Graph? If each resource has ONE instance cycle deadlock Each process involved in the cycle is deadlocked Both necessary and sufficient condition for deadlock If each resource has SEVERAL instance cycle deadlock Necessary but not sufficient condition for deadlock 32 OSKomp 08 Deadlocks

32 RAG example R 1 R 3 P 1 R 1 P 2 R 3 P 3 R 2 P 1 P 2 R 3 P 3 R 2 P 2 P 1 P 2 P 3 R 2 P 1, P 2, P 3 are deadlocked R 4 33 OSKomp 08 Deadlocks

33 RAG example P 2 P 1 R 1 P 3 R 2 P 1 R 1 Not in deadlock state. P 1 R 2 P 3 Important because we then can deal with deadlocks (Apply algorithms, induce choice,...) P 4 p 4 may deallocate R 2 34 OSKomp 08 Deadlocks

34 Conditions Mutual exclusion At least one resource must be nonsharable (only one process can use it) Hold and wait At least one process holds at least one resource and waits for more resources which are held by other processes No preemption Only the process holding a resource can release it. Circular wait A set of processes are waiting for resources held by others in a circular manner < P 0,..., P n > where P i waits for a resource held by P i+1[n]. 35 OSKomp 08 Deadlocks

35 Outline 1 Quick recall on Synchronisation 2 Characterizing Deadlocks 3 Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Deadlock Recovery 36 OSKomp 08 Deadlocks

36 How do we proceed? 1 Make sure they never occur deadlock prevention (make sure at least one of the conditions above never hold) deadlock avoidance (keeping more information about processes, allocate resources so that deadlocks cannot appear) 2 Deal with them deadlock detection deadlock recovery (work in pair) 3 Ignore them! if they don t appear too often, it s cheaper to restart the system/processes 37 OSKomp 08 Deadlocks

37 Deadlock Prevention Idea : Make sure one of the conditions is never satisfied. Mutual exclusion Difficult, since some resources cannot be shared (e.g. CPU). For some resources it works fine (e.g. read-only files). 38 OSKomp 08 Deadlocks

38 Deadlock Prevention Hold and wait Make sure that when a process requests a resource, it doesn t hold any other resources. allocate all resources before starting difficult to predict, waste of resources (low utilization) allow resource requests only when the process has none in some cases degenerates to the previous (e.g. printing files from two CDs directly after each other). Risk for starvation for "popular" resources. 39 OSKomp 08 Deadlocks

39 Deadlock Prevention No preemption Preempt (force release) allocated resources. Release all If the process holds a resource, requests another, and can t get it immediately, release all its resources (and have it wait for them all) - cf process scheduling! Release when waiting If the requested resources are not available, but allocated by a process which is waiting for some other resource, steal the resource (deallocate from waiting, allocate to requesting) and have the original holder wait for also this resource. Solutions work for some resource types (e.g. CPU, memory - easy to store and reload state) but not for others (e.g. printers!) 40 OSKomp 08 Deadlocks

40 Deadlock Prevention Circular wait Make a total ordering (<) of all resource types, and only allow requests in this order: If a process has R 1 and requests R 2, allow only if R 1 < R 2 (otherwise must deallocate R 1 first). If several instances of the same type are needed, must allocate all together. 41 OSKomp 08 Deadlocks

41 Deadlock Avoidance Deadlock prevention can lead to low resource utilization and reduced throughput. If the system knows which resources will be requested by each process, and in which order, the system can order the requests so that deadlocks can not occur. Yet difficult to describe, we could require extra information, to take better decision. 42 OSKomp 08 Deadlocks

42 Deadlock Avoidance Easiest solution: each process declares the maximum number of each resource type it will need (e.g. put in the PCB). At each request, the system dynamically checks the resource-allocation state to make sure the circular wait condition will not be satisfied if the request is granted. 43 OSKomp 08 Deadlocks

43 Deadlock Avoidance Safe state Algorithm idea preserve a safe state of resource allocations. safe state: if all processes can be given their maximum resource allocation (in some order) and avoid deadlock. The order of allocations is a safe sequence: < P 1, P 2,..., P n > is a safe sequence for the current allocation state if for each P i, its maximum resource requests can be satisfied using its current resources plus the resources held by all P j where j < i. In order to use the resources of P j, P i may have to wait until they terminate, but P i can get its resources! When P i terminates, P i+1 can get its resources, etc. 44 OSKomp 08 Deadlocks

44 Deadlock Avoidance Safe state If there is no safe sequence, the state is unsafe. An unsafe state may lead to deadlock, but doesn t have to. A safe sequence never leads to deadlock. Refined algorithm idea Allow only allocations which lead to a safe state. a process which requests a resource which is available may have to wait! Thus, the resource utilization may be less than optimal - but there will be no deadlocks. Concrete algorithm The Banker s Algorithm (section 7.5.3). Never allocate the cash so customers can t get all they need. 45 OSKomp 08 Deadlocks

45 Deadlock Detection Need both detection and recovery. Detection algorithms are quite complex Take time and resources. Typically too expensive to do at each allocation Run periodically or when CPU utilization goes down (which could be an indication of a deadlock). How often? Depends on how often deadlocks appear: often means we should check frequently, otherwise the set of waiting process will grow and the cost of recovery will be larger. 46 OSKomp 08 Deadlocks

46 Deadlock Detection P 5 R 1 R 3 R 4 P 5 P 1 P 2 P 3 P 1 P 2 P 3 R 2 P 4 R 5 P 4 One instance of each resource We can use resource allocation graphs (or wait-for graphs constructed from these) and check for cycles. Need to maintain the RAG/WFG, and periodically invoke an algorithm: Overhead. 47 OSKomp 08 Deadlocks

47 Deadlock Detection More instances Use variant of Banker s algorithm (sec 7.6.2). 48 OSKomp 08 Deadlocks

48 Deadlock Recovery In the detection phase, we found which processes were involved in the circular wait. Idea By terminating processes, their resources are reclaimed by the system the deadlock disappears Abort all deadlocked processes Very expensive, since many processes will have to recompute what they had done. Abort one process at a time until deadlock is broken Overhead: after each termination, re-run detection algorithm. 49 OSKomp 08 Deadlocks

49 Deadlock Recovery Process Termination Both methods may result in e.g. inconsistent data in files. If we abort one at a time, we must also consider which process to terminate (and at each stage) depending on the cost. Example considerations: Process priority - especially if users pay to get priority Accumulated runtime - shorter runtime means less recomputations Current resource allocation - number (many means more resources will be returned to the system) and type (e.g. preemtable?) Future resource requirements 50 OSKomp 08 Deadlocks

50 Deadlock Recovery Resource preemption Idea Instead of terminating process, Try preemting resources (by force releasing) until deadlock is broken. 1 Selecting a victim: Which resources? Which processes? minimize costs. 2 Rollback: The process must be able to continue running normally May require backing the process to a safe state safe state computation is difficult Total roll back. 3 Starvation: Avoid preempting/rolling back the same process again and again - cf priority scheduling and cost considerations. 51 OSKomp 08 Deadlocks

Process synchronization

Process synchronization Process synchronization Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008 Shared Resource Remark Sequential program use shared variables Convenience for Global

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

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

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008. CSC 4103 - Operating Systems Spring 2008 Lecture - XII Midterm Review Tevfik Ko!ar Louisiana State University March 4 th, 2008 1 I/O Structure After I/O starts, control returns to user program only upon

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

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

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

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. 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

Process Synchronisation (contd.) Deadlock. Operating Systems. Spring CS5212

Process Synchronisation (contd.) Deadlock. Operating Systems. Spring CS5212 Operating Systems Spring 2009-2010 Outline Process Synchronisation (contd.) 1 Process Synchronisation (contd.) 2 Announcements Presentations: will be held on last teaching week during lectures make a 20-minute

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

Operating systems. Lecture 5. Deadlock: System Model. Deadlock: System Model. Process synchronization Deadlocks. Deadlock: System Model

Operating systems. Lecture 5. Deadlock: System Model. Deadlock: System Model. Process synchronization Deadlocks. Deadlock: System Model Lecture 5 Operating systems Process synchronization Deadlocks Deadlock: System Model Computer system: Processes (program in execution); Resources (CPU, memory space, files, I/O devices, on so on). Deadlock:

More information

The deadlock problem

The deadlock problem Deadlocks Arvind Krishnamurthy Spring 2004 The deadlock problem A set of blocked processes each holding a resource and waiting to acquire a resource held by another process. Example locks A and B P 0 P

More information

PESIT Bangalore South Campus

PESIT Bangalore South Campus INTERNAL ASSESSMENT TEST II Date: 04/04/2018 Max Marks: 40 Subject & Code: Operating Systems 15CS64 Semester: VI (A & B) Name of the faculty: Mrs.Sharmila Banu.A Time: 8.30 am 10.00 am Answer any FIVE

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

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

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

Operating Systems. Deadlocks. Stephan Sigg. November 30, Distributed and Ubiquitous Systems Technische Universität Braunschweig

Operating Systems. Deadlocks. Stephan Sigg. November 30, Distributed and Ubiquitous Systems Technische Universität Braunschweig Operating Systems Deadlocks Stephan Sigg Distributed and Ubiquitous Systems Technische Universität Braunschweig November 30, 2010 Stephan Sigg Operating Systems 1/86 Overview and Structure Introduction

More information

Deadlocks. Deadlock in Resource Sharing Environment. CIT 595 Spring Recap Example. Representing Deadlock

Deadlocks. Deadlock in Resource Sharing Environment. CIT 595 Spring Recap Example. Representing Deadlock Deadlock in Resource Sharing Environment Operating System Deadlocks CIT 595 Spring 2010 A deadlock occurs when 2 or more processes/threads permanently block each other by each having a lock on a resource

More information

Operating Systems. Operating Systems Sina Meraji U of T

Operating Systems. Operating Systems Sina Meraji U of T Operating Systems Operating Systems Sina Meraji U of T Remember example from third week? My_work(id_t id) { /* id can be 0 or 1 */... flag[id] = true; /* indicate entering CS */ while (flag[1-id]) ;/*

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

! 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

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

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

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

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

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

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

!! 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

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

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

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

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

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

Chapter 6: Process Synchronization

Chapter 6: Process Synchronization Chapter 6: Process Synchronization Objectives Introduce Concept of Critical-Section Problem Hardware and Software Solutions of Critical-Section Problem Concept of Atomic Transaction Operating Systems CS

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

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

Deadlock. Disclaimer: some slides are adopted from Dr. Kulkarni s and book authors slides with permission 1

Deadlock. Disclaimer: some slides are adopted from Dr. Kulkarni s and book authors slides with permission 1 Deadlock Disclaimer: some slides are adopted from Dr. Kulkarni s and book authors slides with permission 1 Recap: Synchronization Race condition A situation when two or more threads read and write shared

More information

Lecture 3: Synchronization & Deadlocks

Lecture 3: Synchronization & Deadlocks Lecture 3: Synchronization & Deadlocks Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating

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

Deadlock. Disclaimer: some slides are adopted from Dr. Kulkarni s and book authors slides with permission 1

Deadlock. Disclaimer: some slides are adopted from Dr. Kulkarni s and book authors slides with permission 1 Deadlock Disclaimer: some slides are adopted from Dr. Kulkarni s and book authors slides with permission 1 Recap: Synchronization Race condition A situation when two or more threads read and write shared

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

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

Concept of a process

Concept of a process Concept of a process In the context of this course a process is a program whose execution is in progress States of a process: running, ready, blocked Submit Ready Running Completion Blocked Concurrent

More information

Module 6: Deadlocks. Reading: Chapter 7

Module 6: Deadlocks. Reading: Chapter 7 Module 6: Deadlocks Reading: Chapter 7 Objective: To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks To present a number of different methods

More information

Maximum CPU utilization obtained with multiprogramming. CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait

Maximum CPU utilization obtained with multiprogramming. CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Thread Scheduling Operating Systems Examples Java Thread Scheduling Algorithm Evaluation CPU

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

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

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-3 DEADLOCKS DEADLOCKS

UNIT-3 DEADLOCKS DEADLOCKS UNIT-3 DEADLOCKS Deadlocks: System Model - Deadlock Characterization - Methods for Handling Deadlocks - Deadlock Prevention. Deadlock Avoidance - Deadlock Detection - Recovery from Deadlock DEADLOCKS Definition:

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 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

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

Operating Systems: William Stallings. Starvation. Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall

Operating Systems: William Stallings. Starvation. Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings Chapter 6 Concurrency: Deadlock and Starvation Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall Deadlock

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

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

Last Class: Synchronization Problems!

Last Class: Synchronization Problems! Last Class: Synchronization Problems! Reader Writer Multiple readers, single writer In practice, use read-write locks Dining Philosophers Need to hold multiple resources to perform task Lecture 11, page

More information

Semaphores INF4140. Lecture 3. 0 Book: Andrews - ch.04 ( ) INF4140 ( ) Semaphores Lecture 3 1 / 34

Semaphores INF4140. Lecture 3. 0 Book: Andrews - ch.04 ( ) INF4140 ( ) Semaphores Lecture 3 1 / 34 Semaphores INF4140 13.09.12 Lecture 3 0 Book: Andrews - ch.04 (4.1-4.4) INF4140 (13.09.12 ) Semaphores Lecture 3 1 / 34 Overview Last lecture: Locks and Barriers (complex techniques) No clear difference

More information

Outlook. Deadlock Characterization Deadlock Prevention Deadlock Avoidance

Outlook. Deadlock Characterization Deadlock Prevention Deadlock Avoidance Deadlocks Outlook Deadlock Characterization Deadlock Prevention Deadlock Avoidance Deadlock Detection and Recovery e 2 Deadlock Characterization 3 Motivation System owns many resources of the types Memory,

More information

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University CS 571 Operating Systems Midterm Review Angelos Stavrou, George Mason University Class Midterm: Grading 2 Grading Midterm: 25% Theory Part 60% (1h 30m) Programming Part 40% (1h) Theory Part (Closed Books):

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

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference

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 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

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

Silberschatz, Galvin and Gagne 2013! CPU cycles, memory space, I/O devices! " Silberschatz, Galvin and Gagne 2013!

Silberschatz, Galvin and Gagne 2013! CPU cycles, memory space, I/O devices!  Silberschatz, Galvin and Gagne 2013! Chapter 7: Deadlocks Chapter 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock 7.2 Chapter

More information

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

Chapter 7: Deadlocks. Operating System Concepts 9 th Edition! Silberschatz, Galvin and Gagne 2013! 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

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

Chapters 5 and 6 Concurrency

Chapters 5 and 6 Concurrency Operating Systems: Internals and Design Principles, 6/E William Stallings Chapters 5 and 6 Concurrency Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall Concurrency When several processes/threads

More information

CSE Opera+ng System Principles

CSE Opera+ng System Principles CSE 30341 Opera+ng System Principles Deadlocks Overview System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock

More information

CMSC 412. Announcements

CMSC 412. Announcements CMSC 412 Deadlock Reading Announcements Chapter 7 Midterm next Monday In class Will have a review on Wednesday Project 3 due Friday Project 4 will be posted the same day 1 1 The Deadlock Problem A set

More information

Deadlock. Disclaimer: some slides are adopted from Dr. Kulkarni s and book authors slides with permission 1

Deadlock. Disclaimer: some slides are adopted from Dr. Kulkarni s and book authors slides with permission 1 Deadlock Disclaimer: some slides are adopted from Dr. Kulkarni s and book authors slides with permission 1 Recap: Synchronization Race condition A situation when two or more threads read and write shared

More information

University of Babylon / College of Information Technology / Network Department. Operating System / Dr. Mahdi S. Almhanna & Dr. Rafah M.

University of Babylon / College of Information Technology / Network Department. Operating System / Dr. Mahdi S. Almhanna & Dr. Rafah M. Chapter 6 Methods for Handling Deadlocks Generally speaking, we can deal with the deadlock problem in one of three ways: We can use a protocol to prevent or avoid deadlocks, ensuring that the system will

More information

ICS Principles of Operating Systems. Lectures Set 5- Deadlocks Prof. Nalini Venkatasubramanian

ICS Principles of Operating Systems. Lectures Set 5- Deadlocks Prof. Nalini Venkatasubramanian ICS 143 - Principles of Operating Systems Lectures Set 5- Deadlocks Prof. Nalini Venkatasubramanian nalini@ics.uci.edu Outline System Model Deadlock Characterization Methods for handling deadlocks Deadlock

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

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017 Operating Systems Lecture 4 - Concurrency and Synchronization Adrien Krähenbühl Master of Computer Science PUF - Hồ Chí Minh 2016/2017 Mutual exclusion Hardware solutions Semaphores IPC: Message passing

More information

Last Class: Synchronization Problems. Need to hold multiple resources to perform task. CS377: Operating Systems. Real-world Examples

Last Class: Synchronization Problems. Need to hold multiple resources to perform task. CS377: Operating Systems. Real-world Examples Last Class: Synchronization Problems Reader Writer Multiple readers, single writer In practice, use read-write locks Dining Philosophers Need to hold multiple resources to perform task Lecture 10, page

More information

Interprocess Communication By: Kaushik Vaghani

Interprocess Communication By: Kaushik Vaghani Interprocess Communication By: Kaushik Vaghani Background Race Condition: A situation where several processes access and manipulate the same data concurrently and the outcome of execution depends on the

More information

Chapter 7: Deadlocks CS370 Operating Systems

Chapter 7: Deadlocks CS370 Operating Systems Chapter 7: Deadlocks CS370 Operating Systems Objectives: Description of deadlocks, which prevent sets of concurrent processes from completing their tasks Different methods for preventing or avoiding deadlocks

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

IV. Process Synchronisation

IV. Process Synchronisation IV. Process Synchronisation Operating Systems Stefan Klinger Database & Information Systems Group University of Konstanz Summer Term 2009 Background Multiprogramming Multiple processes are executed asynchronously.

More information

Process Synchronization

Process Synchronization CSC 4103 - Operating Systems Spring 2007 Lecture - VI Process Synchronization Tevfik Koşar Louisiana State University February 6 th, 2007 1 Roadmap Process Synchronization The Critical-Section Problem

More information

Chapter 8: Deadlocks. Operating System Concepts with Java

Chapter 8: Deadlocks. Operating System Concepts with Java 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

Final Exam Review. CPSC 457, Spring 2016 June 29-30, M. Reza Zakerinasab Department of Computer Science, University of Calgary

Final Exam Review. CPSC 457, Spring 2016 June 29-30, M. Reza Zakerinasab Department of Computer Science, University of Calgary Final Exam Review CPSC 457, Spring 2016 June 29-30, 2015 M. Reza Zakerinasab Department of Computer Science, University of Calgary Final Exam Components Final Exam: Monday July 4, 2016 @ 8 am in ICT 121

More information

Deadlock Prevention. Restrain the ways request can be made. Mutual Exclusion not required for sharable resources; must hold for nonsharable resources.

Deadlock Prevention. Restrain the ways request can be made. Mutual Exclusion not required for sharable resources; must hold for nonsharable resources. Deadlock Prevention Restrain the ways request can be made. Mutual Exclusion not required for sharable resources; must hold for nonsharable resources. Hold and Wait must guarantee that whenever a process

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

Process Synchronization: Semaphores. CSSE 332 Operating Systems Rose-Hulman Institute of Technology

Process Synchronization: Semaphores. CSSE 332 Operating Systems Rose-Hulman Institute of Technology Process Synchronization: Semaphores CSSE 332 Operating Systems Rose-Hulman Institute of Technology Critical-section problem solution 1. Mutual Exclusion - If process Pi is executing in its critical section,

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

Readings and References. Deadlock. Deadlock. Simple Traffic Gridlock Example. Reading. CSE Computer Systems November 30, 2001.

Readings and References. Deadlock. Deadlock. Simple Traffic Gridlock Example. Reading. CSE Computer Systems November 30, 2001. Readings and References Deadlock Reading Chapter 8, Operating System Concepts, Silberschatz, Galvin, and Gagne CSE 410 - Computer Systems November 30, 2001 Other References 30-Nov-01 CSE 410 - Deadlock

More information

Deadlocks. Mehdi Kargahi School of ECE University of Tehran Spring 2008

Deadlocks. Mehdi Kargahi School of ECE University of Tehran Spring 2008 Deadlocks Mehdi Kargahi School of ECE University of Tehran Spring 2008 What is a Deadlock Processes use resources in the following sequence: Request Use Release A number of processes may participate in

More information

PROCESS SYNCHRONIZATION

PROCESS SYNCHRONIZATION PROCESS SYNCHRONIZATION Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization

More information

Dealing with Issues for Interprocess Communication

Dealing with Issues for Interprocess Communication Dealing with Issues for Interprocess Communication Ref Section 2.3 Tanenbaum 7.1 Overview Processes frequently need to communicate with other processes. In a shell pipe the o/p of one process is passed

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

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