Outline for today Objective: Administrative: Background on deadlock

Slides:



Advertisements
Similar presentations
Chapter 7: Deadlocks.
Advertisements

Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Deadlock Prevention, Avoidance, and Detection
ICS Principles of Operating Systems Lectures 8 and 9 - Deadlocks Prof. Dmitri V. Kalashnikov dvk ics.uci.edu Slides © Prof. Nalini Venkatasubramanian.
Deadlock and Starvation
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
Operating Systems Lecture Notes Deadlocks Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Deadlock Prevention, Avoidance, and Detection.  The Deadlock problem The Deadlock problem  Conditions for deadlocks Conditions for deadlocks  Graph-theoretic.
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Fall 2003 URL: Basics of Deadlock Theory.
6. Deadlocks 6.1 Deadlocks with Reusable and Consumable Resources
Chapter 6 Concurrency: Deadlock and Starvation
Chapter 6 Concurrency: Deadlock and Starvation
Deadlock April 19, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Deadlocks. 2 System Model There are non-shared computer resources –Maybe more than one instance –Printers, Semaphores, Tape drives, CPU Processes need.
Deadlock Prevention CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
1 Concurrency: Deadlock and Starvation Chapter 6.
Deadlock. Example Process 1 Process 2 Resource 1 Resource 2.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic,
1 Announcements The fixing the bug part of Lab 4’s assignment 2 is now considered extra credit. Comments for the code should be on the parts you wrote.
Chapter 7 – Deadlock (Pgs 283 – 306). Overview  When a set of processes is prevented from completing because each is preventing the other from accessing.
Outline for Today Announcements –1 st programming assignment coming soon. Objective of the lecture –OS and Virtual Machines.
Chapter 8: Deadlocks Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock.
CS 346 – Chapter 7 Deadlock –Properties –Analysis: directed graph Handle –Prevent –Avoid Safe states and the Banker’s algorithm –Detect –Recover.
Ch 3 –What is a deadlock ? –Conditions Hold and Wait Mutual Exclusion Non Preemption Circular Wait –Deadlock Models Single Unit Request AND Request OR.
Silberschatz, Galvin and Gagne ©2009 Edited by Khoury, 2015 Operating System Concepts – 9 th Edition, Chapter 7: Deadlocks.
Deadlock. Stepping on each other’s feet - I Thread T 1 b1:= allocate(); b2:= allocate(); …… release(b1); release(b2); Thread T 2 b1:= allocate(); b2:=
Outline Objective for today: Formal treatment of deadlock.
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.
ICS Deadlocks 6.1 Deadlocks with Reusable and Consumable Resources 6.2 Approaches to the Deadlock Problem 6.3 A System Model –Resource Graphs –State.
7: Deadlocks1 OPERATING SYSTEMS DEADLOCKS. 7: Deadlocks2 What Is In This Chapter? What is a deadlock? Staying Safe: Preventing and Avoiding Deadlocks.
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);
Deadlock. Examples You can't get a job without experience; you can't get experience without a job. A set of blocked processes each holding a resource.
Chapter 7: Deadlocks.
OPERATING SYSTEM CONCEPTS AND PRACTISE
Process Management Deadlocks.
Chapter 7: Deadlocks.
CSE 120 Principles of Operating
Ch 3 What is a deadlock ? Conditions Deadlock Models Hold and Wait
Outline Objective for today: Formal treatment of deadlock. Bring Zax
Concurrency: Deadlock and Starvation
Operating systems Deadlocks.
Deadlock Management.
ITEC 202 Operating Systems
G.Anuradha Ref:- Galvin
Chapter 7: Deadlocks.
Operating System: DEADLOCKS
ICS 143 Principles of Operating Systems
Chapter 7 Deadlock.
Chapter 7 Deadlocks.
Chapter 7: Deadlocks.
Process Deadlocks.
Operating systems Deadlocks.
Lecture 6: Deadlocks, Deadlock Risk Management
Chapter 7: Deadlocks.
CSc 552 Advanced Unix Process deadlock deadlock prevention
DEADLOCK.
Lecture 27 Syed Mansoor Sarwar
Chapter 7: Deadlocks.
Deadlock Hank Levy 1.
CSE 153 Design of Operating Systems Winter 2019
IT3002 Computer Architecture
OPERATING SYSTEMS DEADLOCKS.
DEADLOCKS.
Operating Systems Principles Process Management and Coordination Lecture 6: Deadlocks 主講人:虞台文.
Chapter 7: Deadlocks.
Chapter 7: Deadlocks.
CSE 542: Operating Systems
CSE 542: Operating Systems
Presentation transcript:

Outline for today Objective: Administrative: Background on deadlock Pulse Speculative execution Virtual Machines and Xen Administrative: Make teams for programming projects Bring Zax This lecture is too short for stand-alone. ADD SOMETHING

Background on Deadlock

Dealing with Deadlock It can be prevented by breaking one of the prerequisite conditions (review): Mutually exclusive use of resources Example: Allowing shared access to read-only files (readers/writers problem from readers point of view) circular waiting Example: Define an ordering on resources and acquire them in order (lower numbered fork first) hold and wait no pre-emption

Dealing with Deadlock (cont.) Let it happen, then detect it and recover via externally-imposed preemption of resources Avoid dynamically by monitoring resource requests and denying some. Banker’s Algorithm ...

Deadlock Theory Resource R0 R1 Process P0 Process P1 Request Arc Alloc Arc State of resource allocation captured in Resource Graph Bipartite graph model with a set P of vertices representing processes and a set R for resources. Directed edges RiPj means Ri alloc to Pj PjRi means Pj requests Ri Resource vertices contain units of the resource Reusable Resources

Deadlock Theory State transitions by operations: Resource R0 R1 Process P0 Process P1 Request Arc Alloc Arc State transitions by operations: Granting a request Making a new request if all outstanding requests satisfied Deadlock defined on graph: Pi is blocked in state S if there is no operation Pi can perform Pi is deadlocked if it is blocked in all reachable states from S S is safe if no reachable state is a deadlock state (i.e., having some deadlocked process)

Deadlock Theory Cycle in graph is a necessary condition no cycle no deadlock. No deadlock iff graph is completely reducible Intuition: Analyze graph, asking if deadlock is inevitable from this state by simulating most favorable state transitions. Request Arc Alloc Arc R0 R1 P1 P3

Deadlock Detection Algorithm Let U be the set of processes that have yet to be reduced. Initially U = P. Consider only reusable resources. while (there exist unblocked processes in U) { Remove unblocked Pi from U; Cancel Pi’s outstanding requests; Release Pi’s allocated resources; /* possibly unblocking other Pk in U */} if ( U != ) signal deadlock;

Deadlock Detection Example R2 R4 R0 R3 R1 P0 P3 P4

Deadlock Detection Example R2 R4 R0 R3 R1 P0 P3 P4

Deadlock Detection Example R2 R4 R0 R3 R1 P0 P3 P4

Deadlock Detection Example R2 R4 R0 R3 R1 P0 P3 P4

Deadlock Detection Example R2 R4 R0 R3 R1 P0 P4

Deadlock Detection Example R2 R4 R0 R3 R1 P0 P4

Deadlock Detection Example R2 R4 R0 R3 R1 P0 P4

Deadlock Detection Example R2 R4 R0 R3 R1 P0 P4

Deadlock Detection Example R2 R4 R0 R3 R1 P0

Deadlock Detection Example R2 R4 R0 R3 R1 Completely Reducible

Another Example P0 Request Alloc Arc Arc R0 R1 P1 With and without P2

Another Example P0 Request Alloc Arc Arc R0 R1 P1 Is there an unblocked process to start with? With and without P2

Another Example P0 Request Arc Alloc Arc R0 R1 P1 With and without P2

Another Example P0 Request Arc Alloc Arc R0 R1 P1 With and without P2

Another Example P0 Request Arc Alloc Arc R0 R1 P1 With and without P2

Another Example P0 Request Alloc Arc Arc R0 R1 Is there an unblocked process to start with? P1 With and without P2 P2

Consumable Resources P0 P1 P2 Producer Arc R0 R1 Not a fixed number of units, operations of producing and consuming (e.g. messages) Ordering matters on applying reductions Reducing by producer makes “enough” units, 

Consumable Resources R0 Producer Arc Not a fixed number of units, operations of producing and consuming (e.g. messages) Ordering matters on applying reductions Reducing by producer makes “enough” units,  Start with P2 P0 P1 Producer Arc P2 R1

Consumable Resources R0 Producer Arc Not a fixed number of units, operations of producing and consuming (e.g. messages) Ordering matters on applying reductions Reducing by producer makes “enough” units,  Start with P2 P0 P1 Producer Arc P2 R1 Not reducible

Consumable Resources R0 Producer Arc R0 R1 Not a fixed number of units, operations of producing and consuming (e.g. messages) Ordering matters on applying reductions Reducing by producer makes “enough” units,  Start with P2

Consumable Resources R0 Producer Arc Not a fixed number of units, operations of producing and consuming (e.g. messages) Ordering matters on applying reductions Reducing by producer makes “enough” units,  Start with P2 Start with P1 P0 P1 Producer Arc P2 R1

Consumable Resources  R0 Producer Arc Not a fixed number of units, operations of producing and consuming (e.g. messages) Ordering matters on applying reductions Reducing by producer makes “enough” units,  Start with P1 P0  P1 Producer Arc P2 R1

Consumable Resources   R0 Producer Arc Not a fixed number of units, operations of producing and consuming (e.g. messages) Ordering matters on applying reductions Reducing by producer makes “enough” units,  Start with P1 P0  P1 Producer Arc P2  R1

Consumable Resources R0 Producer Arc Not a fixed number of units, operations of producing and consuming (e.g. messages) Ordering matters on applying reductions Reducing by producer makes “enough” units,  Start with P1 P0 P1 Producer Arc P2 R1 Reducible

Deadlock Detection & Recovery Continuous monitoring and running this algorithm are expensive. What to do when a deadlock is detected? Abort deadlocked processes (will result in restarts). Preempt resources from selected processes, rolling back the victims to a previous state (undoing effects of work that has been done) Watch out for starvation.

Pulse

Goal To increase the kinds of deadlocks that can be detected dynamically Uses high-level speculative execution to go forward to discover dependencies

Overview of Pulse Kernel daemon process Presence of long-sleeping processes trigger detection Detection mode Identify processes and events awaited Fork speculative processes to see what events they generate in the future

Creating General Resource Graph with Consumable Resources

Details of Graph Construction Process and Event nodes Those processes blocked a long time. Events – all blocking system calls modified to record the events for which caller waits (resource, condition <op, val>) Edges Request edges generated with event nodes. Producer edges result from speculation Recorded in event buffer until speculative processes terminate (normally, full buffer, timeout) Modifying all system calls that unblock the blocking ones Cycle detection on finished graph

Safe Speculation Must not modify state of any other process Fork with copy-on-write enabled Can not change shared kernel data structures Can not write to files Can not send signals to another process Pretend properly that we get unblocked ourselves Not really reading input data if that’s what we were waiting for (so data dependent branches won’t be “right”) Must pretend that conditions true (in case of while loop in application code)

Tricks of Forking Blocked Processes New process is forced to run ret_from_spec_fork Fake the awaited event syscall_exit with success

5 Dining Philosophers

Smoker’s Problem Suppose agent releases tobacco and matches

Apache Bug

Limitations False positives False negatives Since everything appears as consumable resources, Pulse could find more than one producer edge (and extra cycles) Since more than single unit resources – a cycle is really just necessary not sufficient False negatives Self-breaking mechanisms Events that never occur (no unlocks)

Extensions Spinning synchronization – we just need to identify spinning as form of blocking by the system – instrument calls Kernel deadlocks – use virtual machine to speculatively execute a kernel instance.

Intro to Virtual Machines

Traditional Multiprogrammed OS Multiple applications running with the abstraction of dedicated machine provided by OS Pass through of non-privileged instructions ISA – instruction set architecture ABI – application binary interface Application(s) ABI Syscalls OS ISA instr HW

©James Smith, U.Wisc

Virtualization Layer ©James Smith, U.Wisc

Virtual Machines History: invented by IBM in 1960’s Fully protected and isolated copy of the physical machine providing the abstraction of a dedicated machine Layer: Virtual Machine Monitor (VMM) Replicating machine for multiple OSs Security Isolation ©James Smith, U.Wisc

Virtual Machine Monitor ©J. Sugarman, USENIX01

Issues Hardware must be fully virtualizable – all sensitive (privileged) instructions must trap to VMM X86 is not fully virtualizable In traditional model, all devices need drivers in VMM PCs have lots of possible devices – leverage the host OS for its drivers => hosted model

Xen

Paravirtualization A virtual machine that is not identical to real hardware Does not require changes to application interface (support unmodified user code). Does require source modifications to kernel – XenoLinux.

Structure Privilege ring 3 Privilege ring 1 Privilege ring 0

Structure hypercalls events