Class Notes, 3/21/07, Operating Systems
|
|
- Joshua Waters
- 6 years ago
- Views:
Transcription
1 Class Notes, 3/21/07, Operating Systems Hi, Jane. Thanks again for covering the class. One of the main techniques the students need to how to recognize when there is a cycle in a directed graph. (Not all of them have had Discrete Structures yet.) I introduced the concept to them this week, and I think they should be OK with it, but if they re not, maybe give them some more examples. I ve left a few spaces in the notes to add in some pictures. Most of the pictures are straight out of the book, but a few I ve indicated what changes to make. I hope this is all right. The sections I d like you to cover are 7.2.2, 7.5, 7.6 (if you have time). I ve already covered 7.1, 7.2.1, 7.3, 7.4. The banker s algorithm has a lot of details, so if you get to that at the end of class, and have little time left, you can just let them go early. Background A process is a program in the process of being executed on the computer. Often, processes require exclusive use of resources at different points in their execution (resources may be e.g. printers, disk drives, files, or even variables shared among different processes). Exclusive use (mutual exclusion) means that only one process can use a given resource at one time. When a process P needs more than one resource R and R, then it may hold one resource R when it becomes available and at the same time P may have to wait for R, which is held by another process. Deadlock happens e.g. in the following circumstance. Assume P 0 is holding resource R 0 and waiting for R 1, and P 1 is holding R 1 and waiting for R 0. Then neither process can acquire all the resources it needs to continue executing, and there is a deadlock (unless one is preempted i.e., is forced to release a held resource).
2 7.2.2, Resource Allocation Graphs A resource allocation graph has two types of vertices, processes P i, represented by circles, and resources R j represented by rectangles. It may happen that there is more than one instance of a given resource e.g., two identical disk drives. (Different instances of a given resource must be logically and functionally interchangeable: so 2 printers in different wings of a building would generally be considered separate resources, not as 2 instances of the same resource.) Each instance of a resource R j is represented by a dot inside the R j rectangle. There are two types of directed edges (arrows) in a resource allocation graph: P i R j is a request edge, meaning that P i is requesting to use an instance of R j. A directed edge R j P i is an assignment edge, which means that an instance of R j is assigned (held) by P i. Request edges go from the circle P i to the rectangle R j, but assignment edges go from one of the dots inside the rectangle R j to P i (this represents the particular instance of R j which is being held). Do the example for figure 7.2. Note there is no cycle in the graph. Resource allocation graphs can change over time. When
3 a process has all the resources it needs, then we assume that the process will use these resources to complete its task and then release them. When a resource is released, the assignment edge is erased. For example, in figure 7.2, P 3 is not waiting for any other resource other than the R 3 which it holds. So, once it is finished with R 3, the edge R 3 P 3 can be erased. (Draw graph) A resource allocation graph can also change when a process s request for a resource is granted. In this case, a request edge becomes an assignment edge (so the direction of the arrow is switched). Continuing our example above, since R 3 is now available, P 2 s request can be granted, and R 3 can be assigned to P 2. (Draw graph) Now P 2 has all the resources it needs, and so, once it s through, it can release R 1, R 3, and its instance of R 2. Then P 1 can be assigned R 1 and execute, and all of
4 the processes are allowed to finish: there is no deadlock. Note how the graph changed: Since there was no cycle at the beginning, the graph could be unwound from P 3 to P 2 to P 1. (Draw a few subsequent graphs) (Another way a resource allocation graph can change is if a process requests another resource (so a new request edge appears). For now, we re concerned mainly with analyzing the current state of holds & requests, not anticipating future requests that will come in 7.5 below.) Cycles & Deadlocks If there is a cycle in the resource allocation graph, then there may or may not be a deadlock (at least in the case where there are multiple instances of some resources). If there is no cycle in the resource allocation graph, then there is no deadlock. Do the example for Figure 7.3. Explain why there is
5 a deadlock. Do the example for Figure 7.4. Even though there is a cycle, eventually P 2 will release its instance of R 1, which can then be assigned to P 1, breaking the cycle. Draw (at least part of) a possible evolution over time of the graph on the board, until it s obvious enough that all processes can complete their tasks Safe states Draw the Venn diagram on p A safe state is one in which it is always possible (given current requests & holds) to avoid deadlock. An unsafe state may or may not be deadlocked. If we have an algorithm to ensure that the system is always in a safe state, then we can guarantee not to have deadlocks. Our deadlock avoidance algorithms depend on knowing the maximum needs of each process. So a process P may currently need 5 tape drives, but at some point
6 in the future may need a total of 10 tape drives. Its maximum needs are then 10 tape drives. A safe sequence is a sequence of processes P 1,... P n so that P 1 can acquire its maximum resources from the sum of those already held by (allocated to) it & those that are currently free for the system to allocate. Then a subsequent process in the sequence P i must have its maximum needs satisfied by the sum of the resources allocated to P 1,..., P i plus those free in the system. This is a reasonable definition, since the processes P 1,... P n can be executed in this order. So P 4 is allowed to use the resources of P 1, P 2, P 3, since we may assume that P 1, P 2, P 3 have already completed their tasks and have released their resources to the system. Consider the following example, in which P 0, P 1, P 2 need a certain number of tape drives. Assume there are a total of 10 tape drives in the system. The beginning state is 3 free, Process Maximum Needs Current Allocation P P P Then P 1, P 0, P 2 is a safe sequence, since, conceptually, we may think of executing them in that order: 3 free, Process Maximum Needs Current Allocation P P P P 1 can then acquire 2 free drives from the system. Once
7 P 1 finishes, the state is 5 free, Process Maximum Needs Current Allocation P P Now, conceptually, P 0 can acquire the 5 free drives and execute, leaving 10 free, Process Maximum Needs Current Allocation P And finally P 2 can execute. Consider what would happen if we initially allocate one more drive to P 2. Then the state would be 2 free, Process Maximum Needs Current Allocation P P P the same process leads to a possible deadlock (P 1 executes, leaving 4 free drives, but this is not enough, since P 0 may request 5, and P 2 may request 6 at the same time). Thus it is a mistake to allocate an additional drive to P 2 at the beginning, since that will become an unsafe state , Resource-Allocation-Graph Algorithm for Deadlock Avoidance In the case that each resource R i has exactly one instance, we can omit the dots inside the rectangle R i, and simply draw a more traditional graph.
8 The following resource-allocation-graph algorithm only works in the case that each resource has exactly one instance. We introduce a new type of edge to the resourceallocation graph above, called a claim edge. A claim edge P i R j, is drawn with a dotted arrow, and indicates that at some point in the future, P i may request to use R j. (So P i s maximum need for R j is 1, but its current allocation & request for R j is 0). Note that a claim edge is drawn in the same direction as a request edge, since it represents a potential request. A system in which all resources have a single instance is in an unsafe state exactly when there is a cycle in its resource-allocation graph (as augmented here with claim edges). Do the example of figures 7.6, 7.7. Note that 7.7 is an unsafe state, but not a deadlock. This is because the claim edge P 1 R 2 is only a potential request, not an actual request. It is an unsafe state, since if P 1 requests R 2, then there will be an actual deadlock.
9 7.6.1 Resource-Allocation-Graph Algorithm for Deadlock Detection Assume we are still in the case where there is only one instance of each resource. Then we can use the resourceallocation-graph algorithm to detect whether there is currently a deadlock in the system. Since we are now only concerned whether the system is deadlocked, not whether it is in a safe state, there are no claim edges for anticipating future problems, only assignment & request edges. For a system in which each resource has only one instance, there is a deadlock exactly when there is a cycle in the resource allocation graph. (Note this algorithm is exactly the same as the case for Deadlock Avoidance above, the only difference being that we consider only actual, current requests, and not potential, future ones.) Write example 7.8.a. In the case where each resource has only one instance, it is also useful to write down an auxiliary graph, the wait-for graph. This graph is formed from the resourceallocation graph by using only the processes as nodes in the new graph, and by drawing an arrow between processes P i P j only when there is a path P i R k P j
10 that passes through a single resource R k. Recall that this means that P j is holding R k, and P i is requesting R k. This means that P i is waiting for P j to release R k. Write down example 7.8.b. The wait-for graph is less complicated than the resourceallocation graph, and (in the current case each resource has 1 instance) there is a cycle in the wait-for graph exactly when (if and only if) there is a cycle in the resourceallocation graph. The wait-for graph then provides an easier way to check for deadlocks (cycles). Why is it not justified to use the wait-for graph in the case of multiple instances of a resource? Consider two instances of a resource R, one held by P 0, and the other by P 1. If P 2 requests an instance of R, then we have (Draw a small piece of a graph with two arrows coming from the dots in R to each of P 0 and P 1, and an arrow coming from P 2 to R.) Now P 2 is waiting for either P 0 or P 1 to finish, and
11 not for P 0 or P 1 individually (one arrow in wait-for graph P 2 P 0 or P 2 P 0 ), and also not for both P 0 and P 1 at once (two arrows in the wait-for graph). So it s not appropriate to reduce the resource-allocation graph to a wait-for graph. Another example (Dining Philosophers, Chapter 6) (Jane: they ve already seen this example: the new part is drawing the graph.) Recall the dining philosophers problem: 5 philosophers P 0,..., P 4 sit around a round table eating & thinking. In the center of the table is a bowl of rice. There are only 5 chopsticks C 0,..., C 4 on the table, one chopstick in between each pair of philosophers. In order to eat, a philosopher P i must be able to take both the chopsticks on her left C i & right C (i+1)%5, in order to eat. (Jane: % means mod in C++) A deadlock is possible if each philosopher P i, upon getting hungry, first attempts to pick up her left chopstick C i and then attempts to pick up her right chopstick C (i+1)%5. If they all pick up the left chopstick at once, then none of them can pick up the right chopstick, and there is a deadlock. (Jane: I didn t copy chapter 6 for myself, so I m not 100% sure the picture I ve described is exactly the same as the one in the book in terms of numbering the chopsticks.) In this case, the wait-for graph consists of a single cycle P 0 P 1 P 2 P 3 P 4 P 0.
12 Vector Math If X = (1, 3, 4, 7) and Y = (0, 2, 4, 5) are integer 4- dimensional vectors, then we say their difference X Y = (1 0, 3 2, 4 4, 7 5) = (1, 1, 0, 2) So the difference of two vectors is a vector whose components are the differences of the components. (We saw in class a vector sum works similarly.) Matrix addition and substraction work the same way. If X and Y are two vectors of length n, then we say X Y if and only if the components X[i] Y [i] for all i = 1,..., n. For example, (0, 2, 4, 5) (1, 3, 4, 7), but (1, 0, 0, 0) (0, 1000, , ). We say X < Y if X Y but X Y. So (0, 2, 4, 5) < (1, 3, 4, 7). (For those students who have taken Discrete Structures, the definition of for vectors is the product partial order on the set of integral vectors Z n = Z Z.) Banker s Algorithm There are actually 3 slightly different settings in which we can apply the banker s algorithm. They all are for analyzing systems which have resources with multiple instances. The safety algorithm ( ) determines whether the system is in a safe state. The resource-request algorithm ( ) determines whether a given request can be safely granted (i.e. will leave the system in a safe state). Finally, in 7.6.2, the banker s algorithm can be used to detect a deadlock when there are resources with multiple instances. (Safety Algorithm) We have the following data:
13 n processes P 0,..., P n 1, m resources R 0,... R m 1. Available is a vector of m nonnegative integers, representing the number of instances of each resource which are available to be assigned to any process. Available[j] is the number of instances of R j available. Max is an n m matrix. Max[i][j] represents the maximum number of instances of resource R j which process P i may request. Allocation is an n m matrix. Allocation[i][j] is the number of instances of R j currently held by (allocated to) P i. Let Allocation i denote the row of Allocation consisting of the allocation of process P i. We also need three auxiliary structures: Need is an n m matrix representing the maximum number of additional resources each process may need. Need = Max Allocation. Let Need i denote the row of Need consisting of the needs of process P i. Work, an m-vector of integers. Initialize W ork = Available. An n-vector Finish of boolean flags. Initialize F inish[i] = false. The algorithm is as follows: (Jane: == means test for equality, while = means assignment. So if x is a variable with current value 2, then x = x + 2 assigns x
14 the new value 4, while x == x + 2 is false as a Boolean expression.) 1. If possible, find an i so that both F inish[i] == false and Need i W ork. If not possible, go to step Assign W ork = W ork+allocation i. Assign F inish[i] = true. Go back to step If F inish[i] == true for all i, then the system is in a safe state (and the order in which we processed the P i s is a safe sequence). If one or more of the F inish[i] s is false, then we are in an unsafe state. Example. Consider resources A, B, C and processes P 0, P 1, P 2. Assume we have the following initial data (Need is calculated from Allocation & Max): Process Allocation Max Need Available A B C A B C A B C A B C P P P Then the Banker s Algorithm finds that P 2, P 0, P 1 is a safe sequence, and we are in a safe state. Why? Initialize W ork = Available. P 2 is the only process with Need 2 W ork, so initially i = 2. After we process P 2, we have Process Allocation Max Need Work A B C A B C A B C A B C P P (We ve erased P 2, since it is finished, and we have added the resources of P 2 to W ork.) Now Need 0
15 W ork, and so we can choose i = 0. After P 0 is finished, we have Process Allocation Max Need Work A B C A B C A B C A B C P Now Need i W ork, and we can finish with P 1. More? If you have extra time (which I doubt), you can cover (a small modification of the above algorithm), and the example in the book. Thanks again, John
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 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 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 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 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 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 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. 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 informationDeadlock. Chapter Objectives
Deadlock This chapter will discuss the following concepts: The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection
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 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 informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 1018 L14 Deadlocks Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Mutex vs Semaphore 2 2 FAQ Does
More informationOperating 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 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 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 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 informationLecture 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 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 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 informationThe Deadlock Problem
Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock The Deadlock
More informationUniversity 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 informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 16 Deadlock Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Does a cycle in a resource
More informationUNIT-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 informationOperating Systems: (Tue)
Operating Systems: (Tue) Definition: An operating system is the set of software that controls the overall operation of a computer system. provides an interface between the application software and the
More informationOperating 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 informationChapter 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 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 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 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. 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 informationModule 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 informationChapter 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 informationCSE 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 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 informationDeadlocks. 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 informationCS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University
Frequently asked questions from the previous class survey CS 370: OPERATING SYSTEMS [DEADLOCKS] Shrideep Pallickara Computer Science Colorado State University Do most applications have some possibility
More informationChapter 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 informationResource Allocation and Deadlock Handling
Resource Allocation and Deadlock Handling What s in a deadlock Deadlock: A set of blocked processes each waiting for an event (e.g. a resource to become available) that only another process in the set
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 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 informationChapter 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 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 informationDeadlock 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 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 informationRoadmap. Deadlock Prevention. Deadlock Prevention (Cont.) Deadlock Detection. Exercise. Tevfik Koşar. CSE 421/521 - Operating Systems Fall 2012
CSE 421/521 - Operating Systems Fall 2012 Roadmap Lecture - XI Deadlocks - II Deadlocks Deadlock Prevention Deadlock Detection Deadlock Recovery Deadlock Avoidance Tevfik Koşar University at Buffalo October
More informationChapter 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 informationChapter 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 informationDeadlocks. 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 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 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 informationModule 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 informationResource Management and Deadlocks 43
Resource Management and Deadlocks 43 The Deadlock Problem Law passed by the Kansas Legislature in early 20th century: When two trains approach each other at a crossing, both shall come to a full stop and
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 informationChapter 6 Concurrency: Deadlock and Starvation
Operating Systems: Internals and Design Principles Chapter 6 Concurrency: Deadlock and Starvation Seventh Edition By William Stallings Edited by Rana Forsati CSE410 Outline Principles of deadlock Deadlock
More 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 informationModule 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 informationDeadlocks. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University
Deadlocks Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics What is deadlock? Deadlock characterization Four conditions for deadlock
More informationCS370 OperaBng Systems
CS370 OperaBng Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 14 Deadlock Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ What happens if only one program
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 informationChapter 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 informationChapter 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 informationChapter 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 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 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 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 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 informationCMPT 300 Introduction to Operating Systems
CMPT 300 Introduction to Operating Systems Introduction to Deadlocks 1 Preemptible resources Resources that can be taken away from a process without adversely affecting outcome Example: memory (swapping)
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 informationModule 3. DEADLOCK AND STARVATION
This document can be downloaded from www.chetanahegde.in with most recent updates. 1 Module 3. DEADLOCK AND STARVATION 3.1 PRINCIPLES OF DEADLOCK Deadlock can be defined as the permanent blocking of a
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 informationChapter 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 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 informationCHAPTER 6: PROCESS SYNCHRONIZATION
CHAPTER 6: PROCESS SYNCHRONIZATION The slides do not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams. TOPICS Background
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 informationLecture 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 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 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 informationPotential Deadlock Example
Deadlock Handling Notice: The slides for this lecture have been largely based on those accompanying an earlier edition of the course text Operating Systems Concepts, 9th ed., by Silberschatz, Galvin, and
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 informationCSC 539: Operating Systems Structure and Design. Spring 2005
CSC 539: Operating Systems Structure and Design Spring 2005 Process deadlock deadlock prevention deadlock avoidance deadlock detection recovery from deadlock 1 Process deadlock in general, can partition
More informationCHAPTER 7: DEADLOCKS. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.
CHAPTER 7: DEADLOCKS By I-Chen Lin Textbook: Operating System Concepts 9th Ed. Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention
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 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 informationBasic concepts and Terminologies
Deadlock Basic Terminology & Definitions Deadlock, livelock, starvation, resource allocation graph Conditions To Deadlock, Approaches To Deadlock Mutual exclusion, hold and wait, no preemption, circular
More informationCS370: Operating Systems [Spring 2016] Dept. Of Computer Science, Colorado State University
CS 370: OPERATING SYSTEMS [DEADLOCKS] Shrideep Pallickara Computer Science Colorado State University Frequently asked questions from the previous class survey Transactions Can a single process create more
More informationCHAPTER 7 - DEADLOCKS
CHAPTER 7 - DEADLOCKS 1 OBJECTIVES To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks To present a number of different methods for preventing
More informationMaximum 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 informationDeadlocks. 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 informationICS 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 informationCSC Operating Systems Fall Lecture - XII Deadlocks - III. Tevfik Ko!ar. Louisiana State University. October 6 th, 2009
CSC 4103 - Operating Systems Fall 2009 Lecture - XII Deadlocks - III Tevfik Ko!ar Louisiana State University October 6 th, 2009 1 Deadlock Detection Allow system to enter deadlock state Detection algorithm
More informationPESIT 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 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 informationCS307: Operating Systems
CS307: Operating Systems Chentao Wu 吴晨涛 Associate Professor Dept. of Computer Science and Engineering Shanghai Jiao Tong University SEIEE Building 3-513 wuct@cs.sjtu.edu.cn Download Lectures ftp://public.sjtu.edu.cn
More informationChapter 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!! 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 informationOperating 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 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 informationRoadmap. Safe State. Deadlock Avoidance. Basic Facts. Safe, Unsafe, Deadlock State. Tevfik Koşar. CSC Operating Systems Spring 2007
CSC 4103 - Operating Systems Spring 2007 Roadmap Lecture - IX Deadlocks - II Deadlocks Deadlock Avoidance Deadlock Detection Recovery from Deadlock Tevfik Koşar Louisiana State University February 15 th,
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 information