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



Similar documents
Chapter 7: Deadlocks!

OPERATING SYSTEMS DEADLOCKS

The Deadlock Problem. Deadlocks. Deadlocks. Bridge Crossing Example

Resource Allocation and Deadlock Resource Allocation and Handling

Distributed Databases

W4118 Operating Systems. Instructor: Junfeng Yang

Textbook and References

Course Content. Transactions and Concurrency Control. Objectives of Lecture 4 Transactions and Concurrency Control

Introduction to Distributed Systems

In This Lecture. More Concurrency. Deadlocks. Precedence/Wait-For Graphs. Example. Example

Concurrency Control. Module 6, Lectures 1 and 2

Tasks Schedule Analysis in RTAI/Linux-GPL

Objectives. Chapter 5: CPU Scheduling. CPU Scheduler. Non-preemptive and preemptive. Dispatcher. Alternating Sequence of CPU And I/O Bursts

Common Approaches to Real-Time Scheduling

Real Time Scheduling Basic Concepts. Radek Pelánek

Comp 204: Computer Systems and Their Implementation. Lecture 12: Scheduling Algorithms cont d

OS OBJECTIVE QUESTIONS

Transactions. SET08104 Database Systems. Napier University

Unit 12 Database Recovery

Process Scheduling. Process Scheduler. Chapter 7. Context Switch. Scheduler. Selection Strategies

Far-western University Central Office, Mahendranagar Operating System

Announcements. Basic Concepts. Histogram of Typical CPU- Burst Times. Dispatcher. CPU Scheduler. Burst Cycle. Reading

An Overview of Distributed Databases

Monitors, Java, Threads and Processes

Readings for this topic: Silberschatz/Galvin/Gagne Chapter 5

Chapter 10: Distributed DBMS Reliability

Lecture 3 Theoretical Foundations of RTOS

Linux Process Scheduling Policy

(Pessimistic) Timestamp Ordering. Rules for read and write Operations. Pessimistic Timestamp Ordering. Write Operations and Timestamps

On the Unique Games Conjecture

A Group based Time Quantum Round Robin Algorithm using Min-Max Spread Measure

Concepts of Concurrent Computation

Replication on Virtual Machines

W4118 Operating Systems. Instructor: Junfeng Yang

>

/ Operating Systems I. Process Scheduling. Warren R. Carithers Rob Duncan

Transactional properties of DBS

TREE BASIC TERMINOLOGIES

Scheduling 0 : Levels. High level scheduling: Medium level scheduling: Low level scheduling

Operating Systems Concepts: Chapter 7: Scheduling Strategies

System Copy GT Manual 1.8 Last update: 2015/07/13 Basis Technologies

Concurrency Control: Locking, Optimistic, Degrees of Consistency

Chapter 1 8 Essay Question Review

Scheduling policy. ULK3e 7.1. Operating Systems: Scheduling in Linux p. 1

Introduction to Database Management Systems

Aperiodic Task Scheduling

Chapter 15: Recovery System

Topics. Distributed Databases. Desirable Properties. Introduction. Distributed DBMS Architectures. Types of Distributed Databases

Distributed Transactions

Recovery System C H A P T E R16. Practice Exercises

Network (Tree) Topology Inference Based on Prüfer Sequence

Load Balancing in Distributed System. Prof. Ananthanarayana V.S. Dept. Of Information Technology N.I.T.K., Surathkal

CS Fall 2008 Homework 2 Solution Due September 23, 11:59PM

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

Linux scheduler history. We will be talking about the O(1) scheduler

OPERATING SYSTEMS SCHEDULING

Priority Inversion Problem and Deadlock Situations

CSI 333 Lecture 1 Number Systems

Fair Scheduler. Table of contents

Job Scheduling Model

Common Data Structures

Warshall s Algorithm: Transitive Closure

Real-Time Scheduling (Part 1) (Working Draft) Real-Time System Example

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

Transactions: Definition. Transactional properties of DBS. Transactions: Management in DBS. Transactions: Read/Write Model

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

Clock Synchronization

Lecture Outline Overview of real-time scheduling algorithms Outline relative strengths, weaknesses

Today. Intro to real-time scheduling Cyclic executives. Scheduling tables Frames Frame size constraints. Non-independent tasks Pros and cons

Complexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar

Database Concurrency Control and Recovery. Simple database model

Lecture 7: Concurrency control. Rasmus Pagh

Chapter 9: Distributed Mutual Exclusion Algorithms

CPU Scheduling. CPU Scheduling

Homework 8. Revision : 2015/04/14 08:13

Outline. Failure Types

Processor Scheduling. Queues Recall OS maintains various queues

Chapter 14: Recovery System

Chapter 18: Database System Architectures. Centralized Systems

6. Control Structures

Elena Baralis, Silvia Chiusano Politecnico di Torino. Pag. 1. Active database systems. Triggers. Triggers. Active database systems.

Comparison between scheduling algorithms in RTLinux and VxWorks

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

INTRODUCTION TO DATABASE SYSTEMS

Module 3 (14 hrs) Transactions : Transaction Processing Systems(TPS): Properties (or ACID properties) of Transactions Atomicity Consistency

Chapter 5 Process Scheduling

CS414 SP 2007 Assignment 1

Introduction to Software Testing Chapter 8.1 Building Testing Tools Instrumentation. Chapter 8 Outline

Decentralized Utility-based Sensor Network Design

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

Operating Systems OBJECTIVES 7.1 DEFINITION. Chapter 7. Note:

Synchronization in. Distributed Systems. Cooperation and Coordination in. Distributed Systems. Kinds of Synchronization.

SEER PROBABILISTIC SCHEDULING FOR COMMODITY HARDWARE TRANSACTIONAL MEMORY. 27 th Symposium on Parallel Architectures and Algorithms

Transcription:

System model Section 7.1 Resources: CPU, memory, files, devices, semaphores, etc. divided into several types each type has one or more identical instances Processes: 1. Request resource. (If resource cannot be granted immediately, process waits until it can acquire resource.) 2. Use resource. 3. Release resource. Operating Systems: Deadlock p. 1/15

Deadlock conditions Section 7.2 Mutual exclusion: resources cannot be shared Hold and wait: processes must not release resources just because they are waiting No preemption: a resource can only be released voluntarily by the process holding the resource Circular wait: there must exist a set {P 0,..., P n 1 } of waiting processes such that P i is waiting for a resource held by P (i+1) % n, i = 0,..., n 1. Operating Systems: Deadlock p. 2/15

Resource allocation graph Let P = {P 1,..., P n } be set of active processes in the system R = {R 1,..., R m } be set of all resource types in the system V = P R E = E req E assign E req = {P i R j P i has requested an instance of R j and is waiting for it} E assign = {R j P i P i holds an instance ofr j } If the graph does not contain a cycle, no deadlock exists If the graph contains a cycle and each resource node in the cycle has exactly one instance, then deadlock exists Otherwise, deadlock may or may not be present Operating Systems: Deadlock p. 3/15

Resource allocation graph Examples: Operating Systems: Deadlock p. 4/15

Deadlock handling Section 7.3 Prevention: system/processes ensure(s) that at least one of the necessary conditions does not hold Avoidance: processes follow a protocol to ensure that deadlock never happens Recovery Ignore deadlock: system may have to be restarted if deadlock occurs (used in most operating systems) Operating Systems: Deadlock p. 5/15

Deadlock prevention Section 7.4 Hold and wait process must request and be allocated all resources before it begins execution, or a process can request resources only when it has none low resource utilization; starvation possible No Preemption if a process that is holding some resources requests another resource that cannot be immediately allocated to it, then all resources currently being held are released preempted resources are added to the list of resources for which the process is waiting process is restarted only when it can get old resources + newly requested resources Circular Wait all resource types totally ordered processes must requests resources in increasing order Operating Systems: Deadlock p. 6/15

Deadlock avoidance Resource allocation state: # of available / allocated instances of each type maximum demand of each process Section 7.5 Safe sequence: For an allocation state, a sequence P 1,..., P n is safe if for each P i, the maximum resources that P i can request can be satisfied by currently available resources + resources held by all P j (j < i) Safe state: System istb in safe state if there exists a safe sequence consisting of all processes Operating Systems: Deadlock p. 7/15

Deadlock avoidance: RAG algorithm Case I: only one instance of each resource type Claim edge P i R j P i may request resource R j (represented by a dashed line) Claim edge is converted to a request edge when a process requests a resource Assignment edge is converted to a claim edge when a process releases a resource Method: Request P i R j is granted only if converting the request edge to an assignment edge does not result in a cycle in the RAG NOTE: Resources must be claimed a priori Operating Systems: Deadlock p. 8/15

Deadlock avoidance: Banker s algorithm Case II: multiple instances of each resource type Data structures: Available[i]: number of available instances of resource R i Max[i,j]: maximum number of instances that P i may request of resource R j Alloc[i,j]: # of instances of R j currently allocated to P i Request[i,j]: # of instances of R j currently requested by P i Need[i,j]: Max - Alloc Operating Systems: Deadlock p. 9/15

Deadlock avoidance: Banker s algorithm Safety algorithm: Work = Available Finish = {0.. 0} L1: find i such that (Finish[i] = 0 && Need[i] <= Work) if (no such i exists) goto L2 else { Work = Work + Allocation[i] Finish[i] = 1 goto L1 } L2: if (Finish [i] == 1 for all i) return safe return unsafe Operating Systems: Deadlock p. 10/15

Deadlock avoidance: Banker s algorithm Resource allocation algorithm: if (Request[i] > Need[i]) error /* maximum exceeded */ if (Request[i] > Available) wait /* resources not available */ /* pretend to allocate requested resources */ Allocation[i] += Request[i] Available -= Request[i] Need[i] -= Request[i] if (safety_algorithm() == safe) allocate resources else { restore old resource-allocation state put Pi to sleep } Operating Systems: Deadlock p. 11/15

Deadlock detection Section 7.6 Single instance of each resource: Wait-for graph = (V, E) where V = {P 1,..., P n } (set of active processes in the system) E = {P i P j P i is waiting for a resource held by P j } Deadlock exists iff wait-for graph contains a cycle Operating Systems: Deadlock p. 12/15

Deadlock detection Multiple instances of each resource: Data structures: Available[i]: number of available instances of resource R i Alloc[i,j]: # of instances of R j currently allocated to P i Request[i,j]: # of instances of R j currently requested by P i Operating Systems: Deadlock p. 13/15

Deadlock detection Work = Available for each i: if (Alloc[i]!= 0) Finish[i] = 0; else Finish[i] L1: find i such that (Finish[i] = 0 && Request[i] <= Work) if (no such i exists) goto L2 else { Work = Work + Allocation[i] Finish[i] = 1 goto L1 } L2: for each i: if (Finish [i] == 0) Pi is deadlocked Operating Systems: Deadlock p. 14/15

Deadlock recovery Section 7.7 Process termination Abort all deadlocked processes Select one process at a time and abort until deadlock cycle is eliminated priority computation time amount and type of resources held / required Resource preemption Victim selection Starvation Rollback Operating Systems: Deadlock p. 15/15