Deadlock Revisited. CS439: Principles of Computer Systems April 23, 2018
|
|
- Myron McBride
- 6 years ago
- Views:
Transcription
1 Deadlock Revisited CS439: Principles of Computer Systems April 23, 2018
2 Last Time Distributed File Systems Remote Procedure Calls (RPC) Consistency Models Coherence, Staleness, Consistency Network File System (NFS) Google File System (GFS)
3 Today s Agenda RAID Deadlocks What causes them (again) Deadlock Prevention Deadlock Avoidance Banker s algorithm Deadlock Detection Resource Allocation Graphs
4 RAID
5 RAID Redundant Array of Inexpensive Disks Disks are cheap, so put many (10s to 100s) of them in one box to increase storage, performance, and availability Data plus some redundant information is striped across disks Performance and reliability depend on how precisely it is striped 5 different levels 0 improves performance 1 improves reliability 3, 4 & 5 improve both
6 RAID-0: Increasing Throughput This slide is text and an image. Plain text on next slide. Disk striping (RAID-0) Blocks broken into sub-blocks that are stored on separate disks Higher disk bandwidth Poor reliability Failure of a single disk would cause data loss OS disk block Physical disk blocks
7 RAID-0: Increasing Throughput Plain Text Blocks broken into sub-blocks that are stored on separate disks Higher disk bandwidth Poor reliability Failure of a single disk would cause the loss of data Example: OS disk block that holds data: Information stored on disk 1 Information stored on disk 2 Information stored on disk 3
8 RAID-1: Mirrored Disks This slide is text and a picture. Plain text on next slide. To increase disk reliability, we must introduce redundancy Simple scheme: Write to both disks, read from either. On failure, use surviving disk x x Primary disk Mirror disk
9 RAID-1: Mirrored Disks Plain Text To increase disk reliability, we must introduce redundancy Simple scheme: write to both disks, read from either Have 2 disks that each hold all the data for the file system Read from whichever has the head closer to the right spot On failure, use surviving disk Expensive: have to write each change twice Disks marked as primary and mirror
10 RAID-3 This slide is text and a picture. Plain text on next slide. Byte-striped with parity Bytes written to same spot on each disk Reads access all data disks Writes accesses all data disks plus parity disk Disk controller can identify faulty disk Single parity disk can detect and correct errors Example: storing the byte-string 101 in a RAID-3 system x x x x x x x x x x x x x x 0 x x x x x x x x x x x x x x 1 x x x x x x x x x x x x x x
11 RAID-3: Plain Text Byte-striped with parity Bytes written to same spot on each disk Reads access all data disks Writes access all data disks plus parity disk Disk controller can identify faulty disk single parity disk can detect and correct errors Example: storing the byte-string 101 in RAID-3 system with four disks Store 1 on disk 1, 0 on disk 2 and the 2nd 1 on disk 3 Parity on fourth disk parity evenness/oddness of the bits in the string
12 RAID-4 This slide is text and a picture. Plain text on next slide. Block striped with parity Blocks written to same spot on each disk Combines RAID-0 and RAID-3 Reading a block accesses a single disk Writing always accesses parity disk Heavy load on parity disk Disk controller can identify faulty disk Single parity disk can detect and correct errors Disk 1 Disk 2 Disk 3 Parity Disk x x x x RAID-4 layout:
13 RAID-4: Plain Text Block striped with parity Instead of splitting bytes across separate disks you split on block boundaries Blocks written to same spot on each disk Combines RAID-0 and RAID-3 Reading a block accesses a single block Writing always accesses parity disk Heavy load on parity disk Disk controller can identify faulty disk Single parity disk can detect and correct errors
14 RAID-5 This slide is text and a picture. Plain text on next slide. Block Interleaved Distributed Parity No single disk dedicated to parity Parity and data distributed across all disks Disk 1 Disk 2 Disk 3 Disk 4 Disk 5 x x x x x Block x x Block Parity
15 RAID-5: Plain Text Block interleaved distributed parity No single disk dedicated to parity Parity and data distributed across all disks So parity bits spread across multiple disks Example with 5 disks: 4 blocks written to 4 disks (one to each disk) 5 th disk writes parity block Block in same spot on each disk
16 RAID-5 Example This slide is a picture. Text description on next slide. Disk 1 Disk 2 Disk 3 Disk 4 Disk 5 x x x x x Block x Block x+1 Block x+2 Block x Block x Parity m no y z aa x Parity cc dd Block x Parity ff gg x1 0 0 Parity a d g j b ef hi kl c Block bb p s v q tu wx r Block ee hh ii jj1 0
17 RAID-5 Example: Text Description Has 5 separate disks 4 sets of blocks are written In total, 3 blocks of data + 1 parity block are written to each disk First set of blocks: 4 data blocks written to disks 1, 2, 3, 4 Parity block written to disk 5 Second set of blocks: 4 data blocks written to disks 2, 3, 4, 5 Parity block written to disk 1 Third set of blocks: 4 data blocks written to disks 3, 4, 5, 1 Parity block written to disk 2 Fourth set of blocks: 4 data blocks written to disks 4, 5, 1, 2 Parity block written to disk 3 Note that in this example, disk 4 does not write a parity block. If the example were to be extended by one data set, it would be disk 4 s turn.
18 RAID-10 and RAID-50 This slide is text followed by a picture. Plain text on next slide. RAID-10 stripes (RAID-0) across reliable logical disks, implemented as mirrored disks (RAID-1) RAID-50 stripes (RAID-0) across groups of disks with block interleaved distributed parity (RAID-5)
19 RAID-10 and RAID-50: Plain Text RAID-10 Stripes (RAID-0) across reliable logical disks, implemented as mirrored disks (RAID-1) RAID-50 Stripes (RAID-0) across groups of disks with block interleaved distributed parity (RAID-5) Example: Write is striped (RAID-0) to two sets of disks implemented RAID-5.
20 Who is in control? Hardware Pros: Tends to be reliable (hardware implementers test) Offloads parity computation from CPU Cons Dependent on card for recovery (replacements?) Must buy card (for the PCI bus) Serial reconstruction of lost disk Software Pros Other OS instances might be able to recover No additional cost Parallel reconstruction of lost disk Cons Software has bugs Ties up CPU to compute parity
21 Deadlock Revisited
22 Deadlock, More Formally Deadlock occurs when two or more threads or processes are waiting for an event that can only be generated by these same threads or processes Deadlock is not starvation Starvation can occur without deadlock occurs when a thread or process waits indefinitely for some resources, but other threads or processes are actually using it But deadlock does imply starvation
23 Necessary Conditions for Deadlock Deadlock can occur if all of the following conditions hold: 1. Bounded Resources: a finite number of threads or processes can use a resource and resources are finite relaxation of mutual exclusion condition 2. Hold and Wait: at least one thread or process holds a resources and is waiting for other resources to become available. A different thread holds the resource. 3. No Pre-emption: a thread or process only releases a resource voluntarily; another thread, process, or the OS cannot force the thread or process to release the resource 4. Circular Wait: A set of waiting processes or threads {t 1,, t n } where t i is waiting on t i+1 (i=1 to n) and t n is waiting on t 1
24 Managing Deadlocks Deadlock prevention adopts a policy that breaks one of the four conditions Deadlock avoidance algorithms check resource requests and possible availability to prevent deadlock Guarantee that deadlock will never occur Breaks one of the four necessary conditions Deadlock detection algorithms find instances of deadlock and try to recover Admit the possibility of deadlock occurring and periodically check for it
25 Order all resources Deadlock Prevention: Resource Ordering For our code, this was lock ordering All code grabs resources in a predefined order Complications: Maintaining global order is difficult Global order can force a client to grab a resource earlier than it would like, tying up a resource for longer than necessary
26 Deadlock Avoidance: The Banker s Algorithm This slide is a picture and text. Plain text on next slide. Allows sum of maximum resource needs to exceed the total available resources as long as there exists a schedule of loan fulfillments such that all clients can: Receive their maximal loan Build their respective houses Pay back all the loan More efficient than atomically acquiring all resources
27 The Banker s Algorithm: Details Banker has N units, but loans out many more Okay as long as N+1 units are not needed at the same time Uses safe and unsafe states Safe states are states where enough resources are potentially available such that at least one process can run to completion Unsafe states may lead to deadlock If resource request leads to an unsafe state, request is denied even if resources are currently available
28 Living Dangerously: Safe, Unsafe, Deadlocked This slide is a picture and text. Plain text on next slide. Safe: For any possible set of resource requests, there exists one safe schedule of processing requests that succeeds in granting all pending and future requests no deadlock as long as system can enforce safe schedule Unsafe: There exists a set of (pending and future) resource requests that leads to a deadlock, for any schedule in which requests are processed unlucky set of requests can force deadlock Deadlocked: The system has at least one deadlock
29 Banker s Algorithm: Example One This example consists of tables. Plain text on next slide. 5 processes, 4 resources Max Needed Currently Allocated Available (to be allocated) R 1 R 2 R 3 R 4 P P P P P R 1 R 2 R 3 R 4 P P P P P R 1 R 2 R 3 R Is this a safe state?
30 Example One: Determining Safety Slides are an animation. Plain text on slide processes, 4 resources Max Needed Currently Allocated Available Max Poss Request R 1 R 2 R 3 R 4 R 1 R 2 R 3 R 4 R 1 R 2 R 3 R 4 R 1 R 2 R 3 R 4 P P P P P P P P P P P P P P P Determine MaxRequest by subtracting Allocated from Maximum
31 Example One: Determining Safety Slides are an animation. Plain text on slide processes, 4 resources Max Needed Currently Allocated Available Max Poss Request R 1 R 2 R 3 R 4 R 1 R 2 R 3 R 4 R 1 R 2 R 3 R 4 R 1 R 2 R 3 R 4 P P P P P P P P P P P P P P P While safe sequence does not include all processes: Is there a P i such that MaxRequest i <= Available? if no, exit with unsafe if yes, add P i to the sequence and set Available = Available + Allocated
32 Example One: Determining SafetyThis example consists of tables. Plain text on next slide. 5 processes, 4 resources Max Needed Currently Allocated Available (to be allocated) R 1 R 2 R 3 R 4 P P P P P R 1 R 2 R 3 R 4 P P P P P R 1 R 2 R 3 R Is this a safe state?
33 Changing Allocations: Determining Safety Slides are tables. Plain text on slide processes, 4 resources Max Needed Currently Allocated Available R 1 R 2 R 3 R 4 P P P P P R 1 R 2 R 3 R 4 P P P P P R 1 R 2 R 3 R P2 wants to change its allocation to Safe?
34 Changing Allocations: Determining Safety Slides are tables. Plain text on slide processes, 4 resources Max Needed Currently Allocated Available Max Poss Request R 1 R 2 R 3 R 4 R 1 R 2 R 3 R 4 R 1 R 2 R 3 R 4 R 1 R 2 R 3 R 4 P P P P P P P P P P P P P P P Safe?
35 5 processes, 3 resources Example Two Slides are an animation with tables. Plain text on slide 26. Currently Allocated Available Max Poss Request R 1 R 2 R 3 P P P P P R 1 R 2 R R 1 R 2 R 3 P P P P P Given the set of possible requests is there a safe sequence? If no, then deadlock!
36 Example Two, Slightly Changed 5 processes, 3 resources Currently Allocated Available Max Poss Request R 1 R 2 R 3 P P P P P R 1 R 2 R R 1 R 2 R 3 P P P P P Given the set of possible requests is there a safe sequence? If no, then deadlock!
37 iclicker Question The Banker s Algorithm is a good choice for deadlock avoidance in a modern day OS. A. True B. False
38 Weaknesses of Deadlock Avoidance Algorithms Must know resource requests of processes up front (and trust the programmer!) Processes may not enter the system Resources are assumed to always be working
39 Deadlock Detection
40 Resource Allocation Graphs Loosely, graphs the state of resources in the system Used to detect deadlock Threads/processes are represented by circles Resources are represented by squares Arrows represent dependency Arrows from processes/threads to resources indicate waiting for Arrows from resources to threads/processes indicate owned by
41 Resource Allocation Graphs, Formally This slide is words and pictures. Plain text on next slide. Basic components of any resource allocation problem Processes and resources Model the state of a computer system as a directed graph G = (V, E) V = the set of vertices = {P 1,..., P n } È {R 1,..., R m } P i R j E = the set of edges = {edges from a resource to a process} È {edges from a process to a resource} P i request edge allocation edge P k R j
42 Resource Allocation Graphs: An Example This slide is text and a picture. Plain text on next slide. A PostScript interpreter that is waiting for the frame buffer lock and a visualization process that is waiting for memory V = {PS interpret, visualization} È {memory frames, frame buffer lock} Visualization Process Memory Frames PostScript Interpreter Frame Buffer
43 Resource Allocation Graphs: Cycles Slides 35 and 36 are an animation. Plain text on slide 37. Theorem: If a resource allocation graph does not contain a cycle, then no processes are deadlocked. Visualization Process Memory Frames PostScript Interpreter Frame Buffer
44 Resource Allocation Graphs: Cycles Slides 35 and 36 are an animation. Plain text on slide 37. A cycle in a RAG is a necessary condition for deadlock Is the existence of a cycle a sufficient condition? Game Visualization Process Memory Frames PostScript Interpreter Frame Buffer
45 Cycles, In Words If the graph has no cycles, no deadlock exists If the graph has a cycle, deadlock might exist If there is only a single unit of all resources then a set of processes are deadlocked if and only if there is a cycle in the resource allocation graph If there are multiple instances of a resource(s) and any instance of a resource involved in the cycle is held by a thread/process that is not in the cycle, progress might be made when that thread/process releases the resource
46 Deadlock Detection Using a resource allocation graph, scan the graph for cycles, then break the cycles Kill threads or processes in the cycle Kill threads or processes one at a time, forcing each to give up its resources Pre-empt resources one at a time, and rollback the state of the thread/process holding the resource to its state prior to acquiring the resource Common to database transactions
47 Deadlock Detection Detecting cycles in the graph requires O(n 2 ), where n is the number of vertices (processes and resources) When should we execute the algorithm? Just before granting a resource? When a request is denied? On a regular schedule? When CPU utilization drops below some threshold?
48 Deadlock Handling: Real Life Ostrich Algorithm
49 Summary Deadlock is a situation in which a set of threads/processes cannot proceed because each requires resources held by another member of the set. Approaches to handling deadlock are: Prevention: design resource allocation strategies that guarantee that one of the necessary conditions never holds Avoidance: don t allocate a resource if it would introduce a cycle Detection and recovery: recognize deadlock after it has occurred and break it In real life: For resources managed by the program, code carefully! For OS managed resources, ignore the possibility!
50 Announcements Discussion sections this week! Problem Set 11 posted and due in section. Project 4 (Last one!) due Friday, 5/4 No slip days! Final Exam: Thursday, May 10, 7p-10p in JGB Next time: Security!
Deadlock Revisited. CS439: Principles of Computer Systems November 29, 2017
Deadlock Revisited CS439: Principles of Computer Systems November 29, 2017 Last Time Distributed File Systems Remote Procedure Calls (RPC) Consistency Models Coherence, Staleness, Consistency Network File
More informationAdvanced Synchronization and Deadlock
Advanced Synchronization and Deadlock A house of cards? Locks + CV/signal a great way to regulate access to a single shared object......but general multi-threaded programs touch multiple shared objects
More informationLast 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 informationConcurrency Issues. Past lectures: What about coordinated access across multiple objects? Today s lecture:
Deadlock 1 Concurrency Issues Past lectures: Ø Problem: Safely coordinate access to shared resource Ø Solutions: Use semaphores, monitors, locks, condition variables Coordinate access within shared objects
More informationDeadlock and Monitors. CS439: Principles of Computer Systems September 24, 2018
Deadlock and Monitors CS439: Principles of Computer Systems September 24, 2018 Bringing It All Together Processes Abstraction for protection Define address space Threads Share (and communicate) through
More informationA house of cards? Advanced Synchronization and Deadlock. Contra Threads: Events. Contra Threads: Events
A house of cards? Advanced Synchronization and Deadlock Locks + CV/signal a great way to regulate access to a single shared object......but general multi-threaded programs touch multiple shared objects
More informationDeadlock and Monitors. CS439: Principles of Computer Systems February 7, 2018
Deadlock and Monitors CS439: Principles of Computer Systems February 7, 2018 Last Time Terminology Safety and liveness Atomic Instructions, Synchronization, Mutual Exclusion, Critical Sections Synchronization
More information6. Concurrency: Deadlock
CSC400 - Operating Systems 6. Concurrency: Deadlock J. Sumey Deadlock one problem that results from multiprogramming def: a process (or thread) is said to be deadlocked if it is waiting for an event that
More informationIntroduction to I/O and Disk Management
1 Secondary Storage Management Disks just like memory, only different Introduction to I/O and Disk Management Why have disks? Ø Memory is small. Disks are large. Short term storage for memory contents
More informationIntroduction to I/O and Disk Management
Introduction to I/O and Disk Management 1 Secondary Storage Management Disks just like memory, only different Why have disks? Ø Memory is small. Disks are large. Short term storage for memory contents
More informationDUH! Deadlocks. Concurrency Issues. The TENEX Case. If a process requests all systems buffers, operator console tries to print an error message
1 Concurrency Issues Past lectures: Problem: Safely coordinate access to shared resource Solutions: Use semaphores, monitors, locks, condition variables Coordinate access within shared objects Deadlocks
More informationLast 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 informationThe 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 informationMore 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 informationLast 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 informationWhat 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 informationOperating 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 informationOPERATING 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 informationSystem 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 informationChapter seven: Deadlock and Postponement
Chapter seven: Deadlock and Postponement -One problem that arises in multiprogrammed systems is deadlock. A process or thread is in a state of deadlock if it is waiting for a particular event that will
More informationIntroduction 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 informationCSCC 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 informationDeadlocks. System Model
Deadlocks System Model Several processes competing for resources. A process may wait for resources. If another waiting process holds resources, possible deadlock. NB: this is a process-coordination problem
More informationThe 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 informationDeadlocks 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 informationThe Deadlock Problem
Deadlocks 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. P1 and P2 each
More informationECS 150 (Operating Systems) Goal To examine what causes deadlock, and what to do about it. Spring Quarter
D e a d l o c k Goal To examine what causes deadlock, and what to do about it. Spring Quarter 1999 1 The resource manager is that part of the kernel responsible for managing resources. Its process interface
More information! 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!! 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 informationResources. 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 informationChapter 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 informationOperating System: Chap7 Deadlocks. National Tsing-Hua University 2016, Fall Semester
Operating System: Chap7 Deadlocks National Tsing-Hua University 2016, Fall Semester Overview System Model Deadlock Characterization Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from
More informationThe 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 informationCSE325 Principles of Operating Systems. Mass-Storage Systems. David P. Duggan. April 19, 2011
CSE325 Principles of Operating Systems Mass-Storage Systems David P. Duggan dduggan@sandia.gov April 19, 2011 Outline Storage Devices Disk Scheduling FCFS SSTF SCAN, C-SCAN LOOK, C-LOOK Redundant Arrays
More informationConcurrency: Principles of Deadlock. Processes and resources. Concurrency and deadlocks. Operating Systems Fall Processes need resources to run
Concurrency: Principles of Deadlock Operating Systems Fall 2002 Processes and resources Processes need resources to run CPU, memory, disk, etc process waiting for a resource cannot complete its execution
More informationCSE 380 Computer Operating Systems
CSE 380 Computer Operating Systems Instructor: Insup Lee and Dianna Xu University of Pennsylvania, Fall 2003 Lecture Note: Deadlocks 1 Resource Allocation q Examples of computer resources printers tape
More informationDeadlock. Rab Nawaz Jadoon DCS. Assistant Professor COMSATS Lahore Pakistan. Department of Computer Science
Deadlock Rab Nawaz Jadoon DCS COMSATS Institute of Information Technology Assistant Professor COMSATS Lahore Pakistan Operating System Concepts Deadlock A process in a multiprogramming system is said to
More informationDeadlocks. 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 informationOperating 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 informationChapter 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 informationDeadlocks. 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 informationOperating Systems. Deadlocks
Operating Systems Deadlocks Deadlocks Example: two processes want to scan a document, and then save it on a CD P0 down(scanner); down(cd_writer); scan_and_record(); up(cd_writer); up(scanner); P1 down(cd_writer);
More informationCS420: 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 informationCISC 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 informationOPERATING 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 informationProcess 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 informationCOP 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 informationChapter - 4. Deadlocks Important Questions
Chapter - 4 Deadlocks Important Questions 1 1.What do you mean by Deadlocks? A process request for some resources. If the resources are not available at that time, the process enters a waiting state. The
More informationOperating 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 informationCS307 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 informationDeadlocks. 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 informationFinal 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 informationBridge 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 informationCS 153 Design of Operating Systems Winter 2016
CS 153 Design of Operating Systems Winter 2016 Lecture 12: Scheduling & Deadlock Priority Scheduling Priority Scheduling Choose next job based on priority» Airline checkin for first class passengers Can
More informationMODERN 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 Sequence of events required to use a resource: 1. Request the resource. 2. Use the
More informationDeadlock. 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 informationDeadlocks. 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 informationCMSC 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 informationDeadlocks: Detection & Avoidance
Deadlocks: Detection & Avoidance (Chapter 6) CS 4410 Operating Systems The slides are the product of many rounds of teaching CS 4410 by Professors Agarwal, Bracy, George, Sirer, and Van Renesse. System
More informationChapter 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 informationOperating 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 informationDeadlocks Detection and Avoidance. Prof. Sirer CS 4410 Cornell University
Deadlocks Detection and Avoidance Prof. Sirer CS 4410 Cornell University System Model There are non-shared computer resources Maybe more than one instance Printers, Semaphores, Tape drives, CPU Processes
More informationIntroduction 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 informationMODERN 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 informationSystem 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 informationDeadlock Prevention. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han
Deadlock Prevention CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han Announcements HW #3 is due Friday Feb. 25 extra office hours Thursday 1 pm - post this PA #2 assigned, due Thursday March 17 Midterm
More informationChapter 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 informationDeadlocks. 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 informationPrinciples 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 informationModule 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 informationOperating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst
Operating Systems CMPSCI 377 Spring 2017 Mark Corner University of Massachusetts Amherst Clicker Question #1 public static void main(string[] args) { (new Thread(new t1())).start(); (new Thread(new t2())).start();}
More informationDeadlock 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 informationChapter 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 informationDeadlock. 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 informationCS 318 Principles of Operating Systems
CS 318 Principles of Operating Systems Fall 2017 Lecture 8: Deadlock Ryan Huang Administrivia Lab 1 deadline extended - Friday 09/29 11:59 pm - Saturday 09/30 11:59 pm [Hard] HW2 out - should try to solve
More informationChapter 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 informationCSE120 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 informationDeadlocks. 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 informationConcurrency: 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 informationPrinciples 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 informationDEADLOCKS 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 informationThe 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 informationDeadlocks: 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 informationChapter 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 informationECE519 Advanced Operating Systems
IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (6 th Week) (Advanced) Operating Systems 6. Concurrency: Deadlock and Starvation 6. Outline Principles of Deadlock
More informationOperating 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 informationMass-Storage Structure
CS 4410 Operating Systems Mass-Storage Structure Summer 2011 Cornell University 1 Today How is data saved in the hard disk? Magnetic disk Disk speed parameters Disk Scheduling RAID Structure 2 Secondary
More informationDeadlock 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 informationCS153: Deadlock. Chengyu Song. Slides modified from Harsha Madhyvasta, Nael Abu-Ghazaleh, and Zhiyun Qian
1 CS153: Deadlock Chengyu Song Slides modified from Harsha Madhyvasta, Nael Abu-Ghazaleh, and Zhiyun Qian 2 Administrivia Lab Lab1 is due this Sunday Demo sessions next week Little book of semaphores First
More informationChapter 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 informationThe 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 informationCOS 318: Operating Systems. Deadlocks. Jaswinder Pal Singh Computer Science Department Princeton University
COS 318: Operating Systems Deadlocks Jaswinder Pal Singh Computer Science Department Princeton University (http://www.cs.princeton.edu/courses/cos318/) Today s Topics u Conditions for a deadlock u Strategies
More informationDeadlocks. 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 informationI/O CANNOT BE IGNORED
LECTURE 13 I/O I/O CANNOT BE IGNORED Assume a program requires 100 seconds, 90 seconds for main memory, 10 seconds for I/O. Assume main memory access improves by ~10% per year and I/O remains the same.
More informationChapter 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 informationChap. 3. Input/Output
Chap. 3. Input/Output 17 janvier 07 3.1 Principles of I/O hardware 3.2 Principles of I/O software 3.3 Deadlocks [3.4 Overview of IO in Minix 3] [3.5 Block Devices in Minix 3] [3.6 RAM Disks] 3.7 Disks
More informationLast Class: Deadlocks. Today
Last Class: Deadlocks Necessary conditions for deadlock: Mutual exclusion Hold and wait No preemption Circular wait Ways of handling deadlock Deadlock detection and recovery Deadlock prevention Deadlock
More informationProcess P holds resource R. Process P is waiting for resource R. P Process P holds T and requests R. R Process Q holds R and requests T
1 Deadlocks ffl Non-sharable resource: the resource can be used by only one process at a time ffl A process may use a resource in only the following sequence: Request: If the resource cannot be granted,
More informationDeadlock. 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 informationChapter 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