ICS 143 Principles of Operating Systems

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

ICS Principles of Operating Systems Lectures 8 and 9 - Deadlocks Prof. Dmitri V. Kalashnikov dvk ics.uci.edu Slides © Prof. Nalini Venkatasubramanian.
Chapter 7: Deadlocks.
Deadlocks CS 3100 Deadlocks1. The Deadlock Problem A set of blocked processes each holding a resource and waiting to acquire a resource held by another.
Chapter 7: Deadlocks. 7.2 Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 7: Deadlocks.
Deadlocks Gordon College Stephen Brinton. Deadlock Overview The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 7: Deadlock Dr. Mohamed Hefeeda.
What we will cover…  The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Deadlocks.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
Cosc 4740 Chapter 6, Part 4 Deadlocks. The Deadlock Problem A set of blocked processes each holding a resource and waiting to acquire a resource held.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-6 Deadlocks Department of Computer Science and Software Engineering.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 AE4B33OSS Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock Characterization.
CHAPTER 8: DEADLOCKS System Model Deadlock Characterization
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
CS6502 Operating Systems - Dr. J. Garrido Deadlock – Part 2 (Lecture 7a) CS5002 Operating Systems Dr. Jose M. Garrido.
 The Deadlock Problem  System Model  Deadlock Characterization  Methods for Handling Deadlocks  Deadlock Prevention  Deadlock Avoidance  Deadlock.
Dr. Kalpakis CMSC 421, Operating Systems Deadlocks.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks System Model Deadlock Characterization Methods.
Styresystemer og Multiprogrammering Block 3, 2005 Deadlocks Robert Glück.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 7 Operating Systems.
CS307 Operating Systems Deadlocks Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2012.
Chap 7 Deadlocks. Chapter Objectives To develop a description of deadlocks, which prevent sets of concurrent processes from completing their tasks To.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 6 Deadlocks Slide 1 Chapter 6 Deadlocks.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Deadlock.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 7: Deadlocks The Deadlock Problem System Model Deadlock.
7.1 CSE Department MAITSandeep Tayal 7: Deadlocks System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
Deadlocks CPE Operating Systems
Chapter 7: Deadlocks. 7.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 14, 2005 Chapter 7: Deadlocks The Deadlock.
CSE Operating System Principles Deadlocks. CSE – Operating System Principles2 Overview System Model Deadlock Characterization Methods for.
Lecture 6 Deadlock 1. Deadlock and Starvation Let S and Q be two semaphores initialized to 1 P 0 P 1 wait (S); wait (Q); wait (Q); wait (S);. signal (S);
Chapter 7: Deadlocks. The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks.
Thursday, February 23, 2012 Chapter 6 homework questions?
Chapter 7: Deadlocks.
OPERATING SYSTEM CONCEPTS AND PRACTISE
Chapter 7: Deadlocks.
Operating System Concepts
ICS Principles of Operating Systems
Deadlock Management.
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks.
Operating System: DEADLOCKS
Chapter 7 Deadlocks.
Process Deadlocks.
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 1/11/2019 B.Ramamurthy.
Lecture 6: Deadlocks, Deadlock Risk Management
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks.
Outline Deadlocks, dead lock prevention, avoidance.
Deadlock Prevention Restrain the ways request can be made.
Deadlock B.Ramamurthy CSE421 2/23/2019 B.Ramamurthy.
Deadlocks Session - 13.
DEADLOCK.
Chapter 7: Deadlocks.
Deadlock B.Ramamurthy CSE421 4/23/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 5/1/2019 B.Ramamurthy.
CSCI 315 Operating Systems Design
Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
Chapter 8: Deadlocks Deadlock Characterization
Deadlock B.Ramamurthy CSE421 8/28/2019 B.Ramamurthy.
Deadlock B.Ramamurthy CSE421 9/3/2019 B.Ramamurthy.
Deadlock CSE 2431: Introduction to Operating Systems
Presentation transcript:

ICS 143 Principles of Operating Systems Discussion Section Week 7

Today Announcements Programming Assignment Homework #3 Lecture Review Pop Quiz #2 11/17/2018

Announcements Programming Assignment Homework #2 scores out now Due Wed, 10 June 2015, 11:55pm via EEE Dropbox Homework #2 scores out now Homework #1 scores will follow shortly Homework #3: Out now on class website Due Thu, 21 May 2015, 11:55pm via EEE Dropbox 11/17/2018

Programming Assignment Assignment description has moved to GitHub: https://github.com/ekinoguz/ProcessSchedulers Scroll down to see README.md Check repo history frequently for updates: https://github.com/ekinoguz/ProcessSchedulers/commit s/master 11/17/2018

Programming Assignment (2) Input: text file One incoming process per line <process-id> <burst-time> <arrival-time> <share> <process-id> <arrival-time> <burst-time> <share> Output: text file One scheduled process per line <process-id> <finish-time> <wait-time> <turnaround- time> Last line: <average-wait-time> <average-turnaround-time> 11/17/2018

Programming Assignment (3) Other updates: New assumption for Proportional Share (PS) scheduler: If PID 3 with share 60 and PID4 with share 10 are in ready queue at the same time, then PID 3 must be scheduled first. Please take a look at `ps5.input` and `ps5.expected` for a complete example. Time limit: Each test must finish within **2.1 seconds**. After that time, timeout will occur and that test will be assumed to have failed. All updates will appear in repo history 11/17/2018

Deadlocks A process is deadlocked if it is waiting for an event that will never occur A process is indefinitely postponed if it is delayed repeatedly over a long period of time while the attention of the system is given to other processes 11/17/2018

Resources Resource: commodity required by a process to execute Serially reusable resources CPU cycles, memory space, I/O devices, files Acquire => use => release Consumable resources Messages, buffers of information, interrupts Create => acquire => use Resource ceases to exist after it has been used 11/17/2018

Deadlock Conditions Necessary and sufficient conditions for deadlock to occur (must hold simultaneously): Mutual exclusion Only one process at a time can use the resource Hold and wait Processes hold resources already allocated to them while waiting for other resources No preemption Resources are released by processes holding them only after that process has completed its task Circular wait A circular chain of processes exists in which each process waits for one or more resources held by the next process in the chain. 11/17/2018

Resource Allocation Graph Process: Resource type with 4 instances: Pi requests instance of Rj: Pi is holding instance of Rj: Deadlock?? 11/17/2018

Deadlocks in Resource Allocation Graphs If graph contains no cycles: NO DEADLOCK If graph contains a cycle: If only one instance per resource type, then deadlock If several instances per resource type, possibility of a deadlock 11/17/2018

Deadlock Management Deadlock detection Deadlock avoidance Allow possibility of a deadlock, determine if deadlock has occurred and which processes and resources are involved Deadlock avoidance Allow possibility of a deadlock, but sidestep it as it occurs Deadlock recovery Allow possibility of a deadlock, detect it; then clear the problem, allowing processes to complete and resources to be reused Deadlock prevention Design the system in such a way that deadlocks can never occur 11/17/2018

Deadlock Prevention How to prevent deadlock? If any of the conditions for deadlock is denied, deadlock is impossible Mutual exclusion: Allow multiple processes to access shared resources at the same time Hold and wait: Guarantee that when a process requests a resource, it does not hold other resources No preemption: Release resources instead of waiting for process completion Circular wait: Require that processes request resources in increasing order: if process holds resource of type N, can only request types > N Price to be paid: reduced performance (overhead), allow data corruption, etc. 11/17/2018

Deadlock Avoidance Banker’s algorithm (Dijkstra): Set of resources, set of customers, banker Each customer tells banker maximum number of resources it needs Customer borrows resources from banker Customer returns resources to banker Customer eventually pays back loan Banker only lends resources if the system will be in a safe state after the loan 11/17/2018

Safe State System is in a safe state if there exists a safe sequence of all processes Sequence <P1, P2, …, Pn> is safe if for each Pi: the resources that Pi can still request can be satisfied with currently available resources and resources held by Pj with j<I If system is in a safe state: NO DEADLOCK If system is in an unsafe state: possibility of deadlock 11/17/2018

Banker’s Algorithm Allocation: How many instances of each resource type a process is currently holding Max: The maximum number of resource instances (per resource type) a process may request Available: How many instances of each resource type are currently available 11/17/2018

Banker’s Algorithm (2) Need: How many more instances of each resource type a process needs to complete Need[i,j] = Max[i,j] – Allocation[i,j] For process i and resource type j 11/17/2018

Banker’s Algorithm (3) ? ≤ Consider P1 requesting (1,0,2). Can the request be granted? Need to make sure Request ≤ Available Request A B C 1 0 2 ≤ ? 11/17/2018

Banker’s Algorithm (4) Is the system in a safe state? If yes, give a safe sequence. Can I run P0? P1? P2? P3? P4? E.g.: Run P1: 5 3 2 etc. … 11/17/2018

Deadlock Detection Allow system to enter deadlock state Detection Algorithm: Periodically invoke an algorithm that searches for a cycle in the graph, but O(n^2)! Detect unsafe sequence via Banker’s algorithm How often to check? Every time a request for allocation cannot be granted immediately Every hour or whenever CPU utilization drops etc. 11/17/2018

Deadlock Recovery How to recover from deadlock: Abort all deadlocked processes Abort one process at a time until deadlock cycle is eliminated In which order should we choose to abort? Select a victim: minimize cost Priority of the process Resources used by process Resources needed by process to complete How many processes will need to be terminated Rollback: return to some safe state, restart process from that state Starvation possible? Yes, same process may always be picked as victim. Fix: Include number of rollback in cost factor 11/17/2018

? Memory Management First-fit: Best-fit: Worst-fit: Allocate the first hole that is big enough Best-fit: Allocate the smallest hole that is big enough Must search entire list, unless ordered in size Worst-fit: Allocate the largest hole Must search entire list First-fit and best-fit are better than worst-fit in terms of speed and storage utilization P0 requests 200KB Main Memory 500KB free ? 780KB free 250KB free 150KB free 11/17/2018

Pop Quiz #2 11/17/2018