Why Study Deadlocks? Overview of Presentation. Commodity vs General Resources. Types of Deadlocks

Similar documents
Chapter 7: Deadlocks!

OPERATING SYSTEMS DEADLOCKS

Priority Inversion Problem and Deadlock Situations

The Deadlock Problem. Deadlocks. Deadlocks. Bridge Crossing Example

Monitors, Java, Threads and Processes

W4118 Operating Systems. Instructor: Junfeng Yang

System model. Section 7.1. Operating Systems: Deadlock p. 1/15

Why Threads Are A Bad Idea (for most purposes)

Resource Allocation and Deadlock Resource Allocation and Handling

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Bigdata High Availability (HA) Architecture

Thread Synchronization and the Java Monitor

Chapter 11 I/O Management and Disk Scheduling

CS11 Java. Fall Lecture 7

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

Chapter 6, The Operating System Machine Level

chapter >> Consumer and Producer Surplus Section 3: Consumer Surplus, Producer Surplus, and the Gains from Trade

Using Power to Improve C Programming Education

Concurrency Control. Module 6, Lectures 1 and 2

Distributed Databases

Action Steps for Setting Up a Successful Home Web Design Business

OS OBJECTIVE QUESTIONS

Chapter 6 Concurrent Programming

ò Paper reading assigned for next Thursday ò Lab 2 due next Friday ò What is cooperative multitasking? ò What is preemptive multitasking?

Last Class: Semaphores

Hadoop Fair Scheduler Design Document

Chapter 18: Database System Architectures. Centralized Systems

Chapter 3 Operating-System Structures

Introduction. Scheduling. Types of scheduling. The basics

The Importance of Software License Server Monitoring

Distributed File Systems

Centralized Systems. A Centralized Computer System. Chapter 18: Database System Architectures

Lotus Domino Backup Strategy

Top Cash Flow Management Strategies. White Paper by CosmoLex Cloud, LLC

Ethernet-based Storage Configuration

Advanced topics: reentrant function

Survey on Job Schedulers in Hadoop Cluster

Real-Time Component Software. slide credits: H. Kopetz, P. Puschner

independent systems in constant communication what they are, why we care, how they work

OPERATING SYSTEMS SCHEDULING

Challenges in Optimizing Job Scheduling on Mesos. Alex Gaudio

Load Testing and Monitoring Web Applications in a Windows Environment

Driving Reuse in the Supply Chain

Topics. Producing Production Quality Software. Concurrent Environments. Why Use Concurrency? Models of concurrency Concurrency in Java

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

Chapter 11 I/O Management and Disk Scheduling

Oracle Architecture. Overview

Boost SQL Server Performance Buffer Pool Extensions & Delayed Durability

Operating Systems CSE 410, Spring File Management. Stephen Wagner Michigan State University

How to design and implement firmware for embedded systems

Linux Process Scheduling Policy

Seven Deadly Sins of Debugging

Autonomous Function in Interstage Application Server

PostgreSQL Concurrency Issues

3088 Lockout-Tagout Training Program Course Outline

! Past few lectures: Ø Locks: provide mutual exclusion Ø Condition variables: provide conditional synchronization

I/O Device and Drivers

Recovery and the ACID properties CMPUT 391: Implementing Durability Recovery Manager Atomicity Durability

Overview of Presentation. (Greek to English dictionary) Different systems have different goals. What should CPU scheduling optimize?

Dr.Backup Release Notes - Version

Operating Systems Lecture #6: Process Management

Predictive modeling for software transactional memory

CPU Scheduling. CPU Scheduling

SYSTEM ecos Embedded Configurable Operating System

6 Synchronization with Semaphores

Perform-Tools. Powering your performance

Semaphores and Monitors: High-level Synchronization Constructs

Memory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation

Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification

Upgrading from Windows Vista to Windows 7

Name: 1. CS372H: Spring 2009 Final Exam

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

Search Engine Architecture

Release Notes for Epilog for Windows Release Notes for Epilog for Windows v1.7/v1.8

Chapter 12 File Management. Roadmap

Chapter 12 File Management

Concepts of Concurrent Computation

Oracle Enterprise Manager 12c New Capabilities for the DBA. Charlie Garry, Director, Product Management Oracle Server Technologies

Thesis Proposal: Improving the Performance of Synchronization in Concurrent Haskell

Math: Study Skills, Note Taking Skills, And Test Taking Strategies

Crystal Reports Server 2008

Draft report of the Survey of Participants in Stage 3 of the Workflow Pilot Non MEs users

Deadlock Victim. dimanche 6 mai 12

Apache Traffic Server Extensible Host Resolution

Transactional Memory

10 Ways to Kill Performance.

A realistic way to make $100 a day

Microkernels & Database OSs. Recovery Management in QuickSilver. DB folks: Stonebraker81. Very different philosophies

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

OPERATING SYSTEM SERVICES


Database Management System Prof. D. Janakiram Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Avoiding Performance Bottlenecks in Hyper-V

Garbage Collection in the Java HotSpot Virtual Machine

Special Notice. Rules. Weiss Schwarz Comprehensive Rules ver Last updated: October 15 th Outline of the Game

Overview and History of Operating Systems

Operating Systems, 6 th ed. Test Bank Chapter 7

Real Time Scheduling Basic Concepts. Radek Pelánek

How To Create A Digital Signature And Sign A Document With Adobe Reader XI

Sage 50 Accounts Construction Industry Scheme (CIS)

Transcription:

Overview of Presentation Overview of dead-locks Deadlock avoidance (advance reservations) Deadlock prevention (four necessary conditions) Related subjects Other types of hangs Detection and recovery Priority inversion Why Study Deadlocks? A major peril in cooperating parallel processes They result in catastrophic system failures They generally result from careless design Finding them through debugging is very painful It is much easier to prevent them at design time An ounce of prevention is worth a pound of cure If you understand them, you can avoid them Types of Deadlocks Different deadlocks require different solutions Commodity resource deadlocks e.g. memory, queue space General resource deadlocks e.g. files, critical sections Heterogeneous multi-resource deadlocks e.g. P1 needs a file, P2 needs memory Producer-consumer deadlocks e.g. P1 needs a file, P2 needs a message from P1 Commodity vs General Resources Commodity Resources clients need an amount of it (e.g. memory) deadlocks result from over-commitment avoidance can be done in resource manager General Resources clients need a specific instance (e.g. files, mutexes) deadlocks result from specific dependency network Prevention often requires help from clients

Avoidance Advance reservations Require advance reservations for commodities Resource manager tracks outstanding promises Only grants reservations if resources are available Over-subscriptions are detected before client runs before client has yet allocated any resources Refused reservation failures must still be handled But these do not result in deadlocks Dilemma: over-booking vs under-utilization Achieving better resource utilization Problem: reservations overestimate requirements clients seldom need all resources all the time all clients won't need max allocation at the same time Question: can one safely over-book resources? What is a safe resource allocation? one where everyone will be able to complete Some people may have to wait for others to complete we must be sure there are no deadlocks Bankers' Algorithm - Assumptions All critical resources are known and quantifiable e.g. money or memory no other resources can cause deadlocks All clients reserve for their maximum requirement they will never need more than this amount If a client gets his maximum, he will complete Upon completion, he frees all his resources those resources then become available for others Bankers' Algorithm Given a resource "state" characterized by: total size of each pool of resources reservations granted to each client for each resource current allocations of each resource to each client A state is "safe" if... enough resources to allow at least one client to finish after that client frees its resources, resulting state is safe and so on, until all clients have completed A proposed allocation can be granted if... the resulting state would still be "safe"

Bankers' Algorithm limitations Quantified resources assumption not all resources are measurable in units other resources can introduce circular dependencies Eventual completion assumption all resources are released when client completes completion is a transaction or batch notion In a time sharing system many tasks run for months Likelihood of resource "convoy" formation reduced parallelism, reduced throughput Practical Commodity Management Advanced reservations are definitely useful e.g. Unix setbreak system call System should guarantee all reservations allocation failures only happen at reservation time failures will not happen at request time system behavior more predictable, easier to handle Clients must deal with reservation failures hang onto resources and try again later doesn't cut it they must complete (or abort) with current resources If they can't they should have reserved more up front! Prudent Advance Reservations System services must never deadlock for memory potential deadlock: swap manager invoked to swap out processes to free up memory may need to allocate memory to build I/O request If no memory available, unable to swap out processes Solution pre-allocate and hoard a few request buffers keep reusing the same ones over and over again Little bit of hoarded memory is a small price to pay General Resource deadlocks Necessary condition #1: mutual exclusion If P 1 is using resource, P 2 cannot use it Necessary condition #2: block holding resources Process already has R 1 blocks to wait for R 2 Necessary condition #3: circular dependencies P 1 has R 1 and needs R 2 while P 2 has R 2 and needs R 1 Necessary condition #4: no preemption/revocation P 1 has R 1 and it can only be freed when P 1 completes

Attack #1 Mutual Exclusion Deadlock requires mutual exclusion P 1 having the resource precludes P 2 from getting it You can't deadlock over a shareable resource Whenever possible, make resources sharable maintain with atomic instructions Even reader/writer locking can help readers become a non-problem writers may be attacked in other ways Attack #2: hold and block Deadlock requires you to block holding resources Allocate all of your resources in a single operation you hold nothing while blocked when you return, you have all or nothing Disallow blocking while holding resources you must release locks prior to blocking reacquire them after you resume (lock dance) Non-blocking requests a request that can't be satisfied immediately will fail Attack #3: circular dependencies Global resource ordering all requesters allocate resources in same order first allocate R 1 and then R 2 afterwards someone else may have R 2 but he doesn't need R 1 assumes we know how to order the resources some objects have natural ordering (e.g. processes) relationships may order (e.g. parents before children) may require a lock dance Attack #4: no preemption/revocation deadlock can be averted by resource confiscation time-outs and lock breaking resource can be reallocated to new client old client gets "stale handle" error and must restart current owner can be killed all resources will be reclaimed from the corpse this is an extreme measure, use it sparingly release R 2, allocate R 1, reacquire R 2

Who can prevent deadlocks? advance reservations operating system, basic APIs, resource managers eliminating mutual exclusion application developer eliminating blocks while holding resources operating system, basic APIs eliminating circular dependencies application developer, resource managers implementing revocation operating system, basic APIs, resource managers Divide and Conquer! You don't have to pick one solution for all resources You have to solve the problem for each resource Solve individual problems any way that you can resource hoards for key system services reservations for commodity resources sharable resources where feasible ordered allocation where feasible lock breaking when nothing else will work OS is only responsible for deadlocks in OS services applications are responsible for their own behavior Closely related forms of "hangs" live-lock process not blocked, but won't free R 1 until it acquires R 2 sleeping beauty process is blocked, awaiting a particular message message must be sent by another process for some (unknown) reason, the message is never sent program goes rogue program continues to run, but ceases to do useful work none of these are true deadlocks Deadlock detection vs "hang" detection Deadlock detection seldom makes sense it is extremely complex to implement only detects "true deadlocks" in enumerated resources Service/application "health monitoring" does monitor progress or submit test transactions if progress is too slow, declare service to be "hung" this is very easy to implement detects and cures a wide range of problems but they all leave you just as hung

Deadlock/Hang Recovery recovery should be automatic determine which service has failed presumably the service whose audit timed out this may be a symptom of some other failure primary recovery kill and restart the failed application switch-operation over to a hot-stand-by determine efficacy of primary recovery retries, and escalations When does formal detection make sense? Problem: Priority Inversion (a demi-deadlock) low priority process P 1 has mutex M 1 and is preempted high priority process P 2 blocks for mutex M 1 process P 2 is effectively reduced to priority of P 1 Solution: mutex priority inheritance detect when the problem when blocking for mutex compare priority of current mutex owner with blocker temporarily promote holder to blocker's priority return to normal priority after mutex is released Deadlock wrap-up deadlocks are a real and common hazard we must be wary of the danger, and prevent them there are different types of resources they are subject to different types of deadlocks there are several techniques for averting deadlock attack the four necessary conditions for deadlock deadlock detection is generally not practical hang detection is more useful recovery mechanisms are also very important