Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
UNIT 3: DEADLOCKUNIT 3: DEADLOCK
MCA IIMCA II
Chapter 7: DeadlocksChapter 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 from Deadlock
Chapter ObjectivesChapter 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,
avoiding, or detecting deadlocks in a computer system
7.1 System Model7.1 System Model

Recommended for you

Operating system Dead lock
Operating system Dead lockOperating system Dead lock
Operating system Dead lock

This document discusses deadlock avoidance techniques. It explains the concepts of safe and unsafe states when allocating resources to processes. The resource allocation graph algorithm uses claim and assignment edges to model potential resource requests. Banker's algorithm requires processes to declare maximum resource needs upfront. It uses an allocation matrix and need matrix to determine if allocating resources to a process will result in an unsafe state. An example demonstrates tracking available resources and determining if processes can safely obtain requested resources without causing deadlock.

deadlock
Operating System Deadlock Galvin
Operating System  Deadlock GalvinOperating System  Deadlock Galvin
Operating System Deadlock Galvin

A document about deadlocks in operating systems is summarized as follows: 1. A deadlock occurs when a set of processes form a circular chain where each process is waiting for a resource held by the next process in the chain. The four conditions for deadlock are mutual exclusion, hold and wait, no preemption, and circular wait. 2. Deadlocks can be modeled using a resource allocation graph where processes and resources are vertices and edges represent resource requests. A cycle in the graph indicates a potential deadlock. 3. Methods for handling deadlocks include prevention, avoidance, and detection/recovery. Prevention ensures deadlock conditions cannot occur while avoidance allows the system to dynamically verify new allocations will not

Deadlock
DeadlockDeadlock
Deadlock

This document discusses operating system topics related to deadlocks, including definitions, properties, prevention, detection, and recovery from deadlocks. It defines deadlock as when a process requests resources that are held by another waiting process, creating a circular wait. Four conditions must be met for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. Techniques to prevent deadlocks include deadlock avoidance using safe states and resource allocation graphs, and deadlock prevention by ensuring one of the four conditions is never satisfied. Deadlock detection uses wait-for graphs or detection algorithms, and recovery options are terminating processes or preempting resources.

preventiondeadlockdeadlock detection
The Deadlock ProblemThe Deadlock Problem
A deadlock consists of a set of blocked processes, each
holding a resource and waiting to acquire a resource held by
another process in the set
Example #1
A system has 2 disk drives
P1 and P2 each hold one disk drive and each needs the other one
Example #2
Semaphores A and B, initialized to 1
P0 P1
wait (A); wait(B)
wait (B); wait(A)
Bridge Crossing ExampleBridge Crossing Example
Traffic only in one direction
The resource is a one-lane bridge
If a deadlock occurs, it can be resolved if one car backs up
(preempt resources and rollback)
Several cars may have to be backed up if a deadlock
occurs
Starvation is possible
System ModelSystem Model
Resource types R1, R2, . . ., Rm
CPU cycles, memory space, I/O devices
Each resource type Ri has 1 or moreinstances
Each process utilizes a resource as follows:
request
use
release
7.2 Deadlock Characterization7.2 Deadlock Characterization

Recommended for you

Deadlocks
Deadlocks Deadlocks
Deadlocks

Deadlocks can be addressed through four main strategies: detection and recovery, avoidance, and prevention. Prevention ensures that at least one of the four conditions for deadlock never occurs, such as by assigning a numeric order to resources and requiring processes request them in that order to avoid circular waits.

Gp1242 007 oer ppt
Gp1242 007 oer pptGp1242 007 oer ppt
Gp1242 007 oer ppt

This document discusses deadlocks in operating systems. It defines deadlock as when a set of blocked processes each hold a resource and wait for a resource held by another process. It then covers methods for handling deadlocks such as prevention, avoidance, detection, and recovery. Prevention ensures deadlock conditions cannot occur. Avoidance allows the system to deny requests that could lead to deadlock. Detection identifies when a deadlock has occurred. Recovery breaks deadlocks by terminating or preempting processes.

ppt_by_niveditadeadlock_gp_1242_007ppt_by_anusha
Chapter 7 - Deadlocks
Chapter 7 - DeadlocksChapter 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

operatingsystemsdeadlocks
Deadlock CharacterizationDeadlock Characterization
Mutual exclusion: only one process at a time can use a
resource
Hold and wait: a process holding at least one resource is
waiting to acquire additional resources held by other
processes
No preemption: a resource can be released only
voluntarily by the process holding it after that process has
completed its task
Circular wait: there exists a set {P0, P1, …, P0} of waiting
processes such that P0 is waiting for a resource that is held
by P1, P1 is waiting for a resource that is held by
P2, …, Pn–1 is waiting for a resource that is held by
Pn, and Pn is waiting for a resource that is held by P0
Deadlock can arise if four conditions hold simultaneously.
Resource-Allocation GraphResource-Allocation Graph
V is partitioned into two types:
P = {P1, P2, …, Pn}, the set consisting of all
the processes in the system
R = {R1, R2, …, Rm}, the set consisting of all
resource types in the system
request edge – directed edge P1 → Rj
assignment edge – directed edge Rj → Pi
A set of vertices V and a set of edges E.
Resource-Allocation Graph (Cont.)Resource-Allocation Graph (Cont.)
Process
Resource Type with 4 instances
Pi requests instance of Rj
Pi is holding an instance of Rj
Pi
Pi
Rj
Rj
Resource Allocation Graph With A DeadlockResource Allocation Graph With A Deadlock
Before P3 requested an
instance of R2
After P3 requested an
instance of R2

Recommended for you

Deadlock detection & prevention
Deadlock detection & preventionDeadlock detection & prevention
Deadlock detection & prevention

The document discusses deadlocks in operating systems. It defines deadlock as when a process waits for a resource held by another waiting process, forming a circular chain of processes waiting for each other. It characterizes deadlock by the conditions of mutual exclusion, hold and wait, no preemption, and circular wait. The document outlines strategies to handle deadlocks through prevention, avoidance, and detection and recovery. It describes resource allocation graphs to model deadlocks and the conditions for deadlocks using AND and OR resource allocation. Finally, it discusses different techniques for deadlock prevention, detection, and recovery in a system.

Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System

In these slides I discussed about deadlock,causes of deadlock,effects of deadlock,conditions of deadlock,resource allocation graph,deadlock handling strategies,deadlock prevention,deadlock avoidance,deadlock avoidance and resolution....I haven't touch algorithms section in these slides.....and last thing I want to say that don't forget to follow me...

 
by AUST
deadlockconditions of deadlockcauses of deadlock
Deadlock Avoidance in Operating System
Deadlock Avoidance in Operating SystemDeadlock Avoidance in Operating System
Deadlock Avoidance in Operating System

Deadlock avoidance methods analyze resource allocation to determine if granting a request would lead to an unsafe state where deadlock could occur. A deadlock happens when multiple processes are waiting indefinitely for resources held by each other in a cyclic dependency. To prevent deadlock, an operating system must have information on current resource availability and allocations, as well as future resource needs. The system only grants requests that will lead to a safe state where there are enough resources for all remaining processes and deadlock is not possible.

software
Graph With A Cycle But No DeadlockGraph With A Cycle But No Deadlock
Process P4 may release its instance of resource type R2. That
resource can then be allocated to P3, thereby breaking the cycle.
Relationship of cycles to deadlocksRelationship of cycles to deadlocks
If a resource allocation graph contains no cycles ⇒ no deadlock
If a resource allocation graph contains a cycle and if only one instance exists per
resource type ⇒ deadlock
If a resource allocation graph contains a cycle and and if several instances
exists per resource type ⇒ possibility of deadlock
7.3 Methods for Handling7.3 Methods for Handling
DeadlocksDeadlocks
Methods for Handling DeadlocksMethods for Handling Deadlocks
Prevention
Ensure that the system will never enter a deadlock state
Avoidance
Ensure that the system will never enter an unsafe state
Detection
Allow the system to enter a deadlock state and then recover
Do Nothing
Ignore the problem and let the user or system administrator respond to the problem;
used by most operating systems, including Windows and UNIX

Recommended for you

Operating system - Deadlock
Operating system - DeadlockOperating system - Deadlock
Operating system - Deadlock

In this presentation i explain about the most important thing in operating system i.e Deadlock. Here i briefly explained what is deadlock, why deadlock occurs, deadlock in real life, methods of handling deadlock. Banker's algorithm and a numerical. I hope its worth sharing!

operating systemdeadlockwhy deadlock occurs
Deadlock avoidance and prevention .. computer networking
Deadlock avoidance and prevention .. computer networkingDeadlock avoidance and prevention .. computer networking
Deadlock avoidance and prevention .. computer networking

Deadlock occurs when processes are blocked waiting for resources held by other processes in a circular chain. There are four necessary conditions for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. Approaches to handle deadlock include prevention, avoidance, and detection/recovery. Prevention methods modify resource allocation to break one of the conditions, avoidance methods allocate resources in a way that avoids unsafe states that could lead to deadlock, and detection/recovery finds and resolves deadlocks after they occur.

Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system

This document discusses deadlocks in operating systems. It defines a deadlock as a set of blocked processes that are each holding a resource and waiting for a resource held by another process. Four conditions must be met for a deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlocks can be modeled using directed resource allocation graphs. Methods for handling deadlocks include prevention, avoidance, detection, and recovery.

7.4 Deadlock Prevention7.4 Deadlock Prevention
Deadlock PreventionDeadlock Prevention
Mutual Exclusion – The mutual-exclusion condition must
hold for non-sharable resources
Hold and Wait – we must guarantee that whenever a
process requests a resource, it does not hold any other
resources
Require a process to request and be allocated all its resources
before it begins execution, or allow a process to request
resources only when the process has none
Result: Low resource utilization; starvation possible
To prevent deadlock, we can restrain the ways that a request can be made
Deadlock Prevention (Cont.)Deadlock Prevention (Cont.)
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
A process will be restarted only when it can regain its old
resources, as well as the new ones that it is requesting
Circular Wait – impose a total ordering of all resource types, and
require that each process requests resources in an increasing order
of enumeration. For example:
F(tape drive) = 1
F(disk drive) = 5
F(printer) = 12
7.5 Deadlock Avoidance7.5 Deadlock Avoidance

Recommended for you

Deadlock- Operating System
Deadlock- Operating SystemDeadlock- Operating System
Deadlock- Operating System

Deadlock occurs when two or more competing processes are each waiting for resources held by the other, resulting in all processes waiting indefinitely. There are four conditions required for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. Techniques to prevent deadlock include attacking each condition: allowing some resources to be shared, requiring processes request all resources at start, allowing preemption of resources, and imposing a global numbering on resource requests.

deadlockdeadlock characteristicsdeadlock definition
Ch8
Ch8Ch8
Ch8

System Model Deadlock Characterization Methods for Handling Deadlocks Deadlock Prevention Deadlock Avoidance Deadlock Detection Recovery from Deadlock Combined Approach to Deadlock Handling

methods for handling deadlocksrecovery from deadlocksystem model deadlock characterization
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURYdeadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURY

This document discusses deadlock detection in distributed systems. It defines deadlock as when a set of processes are permanently blocked waiting for resources held by each other. There are four conditions for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlock can be detected using centralized, hierarchical, or distributed approaches. Goldman's distributed algorithm avoids maintaining a continuous wait-for graph by exchanging blocked process lists to detect cycles that indicate deadlocks.

deadlock detectiondeadlockcentalized
Deadlock AvoidanceDeadlock Avoidance
Simplest and most useful model requires that each process declare
the maximum number of resources of each type that it may need
The deadlock-avoidance algorithm dynamically examines the
resource-allocation state to ensure that there can never be a
circular-wait condition
A resource-allocation state is defined by the number of available
and allocated resources, and the maximum demands of the
processes
Requires that the system has some additional a priori information
available.
a priori: formed or conceived beforehand
Safe StateSafe State
When a process requests an available resource, the system must
decide if immediate allocation leaves the system in a safe state
A system is in a safe state only if there exists a safe sequence
A sequence of processes <P1, P2, …, Pn> is a safe sequence for
the current allocation state if, for each Pi, the resource requests
that Pi can still make, can be satisfied by currently available
resources plus resources held by all Pj, with j < i.
That is:
If the Pi resource needs are not immediately available, then Pi can
wait until all Pj have finished
When Pj is finished, Pi can obtain needed resources, execute, return
allocated resources, and terminate
When Pi terminates, Pi +1 can obtain its needed resources, and so on
Safe State (continued)Safe State (continued)
If a system is in safe state ⇒ no deadlocks
If a system is in unsafe state ⇒ possibility of deadlock
Avoidance ⇒ ensure that a system will never enter an
unsafe state
Safe, Unsafe , Deadlock StateSafe, Unsafe , Deadlock State

Recommended for you

Methods for handling deadlocks
Methods for handling deadlocksMethods for handling deadlocks
Methods for handling deadlocks

There are three main approaches to handling deadlocks: prevention, avoidance, and detection with recovery. Prevention methods constrain how processes request resources to ensure at least one necessary condition for deadlock cannot occur. Avoidance requires advance knowledge of processes' resource needs to decide if requests can be immediately satisfied. Detection identifies when a deadlocked state occurs and recovers by undoing the allocation that caused it.

Deadlock Presentation
Deadlock PresentationDeadlock Presentation
Deadlock Presentation

Salman Ahmed presents on deadlocks in computer systems. A deadlock occurs when two programs are preventing each other from accessing shared resources, causing both programs to cease functioning. Deadlocks happen when processes are holding resources and waiting to acquire more resources, but cannot release the initial resources. There are four main approaches to handling deadlocks: prevention, avoidance, detection, and recovery. Prevention eliminates one of the conditions required for a deadlock, while avoidance allows the system to refuse resource requests to avoid entering a deadlocked state.

deadlockcseoperating system
Banker's note - Blackstone Synergy Pitch
Banker's note - Blackstone Synergy PitchBanker's note - Blackstone Synergy Pitch
Banker's note - Blackstone Synergy Pitch

The document outlines a turnaround algorithm created by Blackstone Synergy Consulting Group to help struggling small and medium enterprises (SMEs) in Kenya. The algorithm involves liquidating debt to allow for organic growth, improving operating fundamentals through skills training and quality enhancements, and restructuring finances. Blackstone would appoint a receiver manager and implement interventions over 12 quarters to transform business processes, with quarterly reviews to track progress on benchmarks. The goal is for SMEs to achieve organic growth, increased equity earnings, and knowledge capital formation to ensure future success.

Avoidance algorithmsAvoidance algorithms
For a single instance of a resource type, use a resource-
allocation graph
For multiple instances of a resource type, use the banker’s
algorithm
Resource-Allocation Graph SchemeResource-Allocation Graph Scheme
Introduce a new kind of edge called a claim edge
Claim edge Pi Rj indicates that process Pj may
request resource Rj; which is represented by a dashed line
A claim edge converts to a request edge when a process
requests a resource
A request edge converts to an assignment edge when the
resource is allocated to the process
When a resource is released by a process, an assignment
edge reconverts to a claim edge
Resources must be claimed a priori in the system
Resource-Allocation Graph withResource-Allocation Graph with
Claim EdgesClaim Edges
Request
edge
Assignment
edge
Claim
edge
Claim
edge
Unsafe State In Resource-Allocation GraphUnsafe State In Resource-Allocation Graph
Assignment
edge
Request
edge
Assignment
edgeClaim
edge

Recommended for you

Bankers
BankersBankers
Bankers

Deadlocks occur when a set of blocked processes each hold resources and wait for resources held by other processes in the set, resulting in a circular wait. The four necessary conditions for deadlock are: mutual exclusion, hold and wait, no preemption, and circular wait. The banker's algorithm is a deadlock avoidance technique that requires processes to declare maximum resource needs upfront. It ensures the system is always in a safe state by delaying resource requests that could lead to an unsafe state where deadlock is possible.

Introduction to Operating system
Introduction to Operating systemIntroduction to Operating system
Introduction to Operating system

This document discusses several topics related to operating systems and computer science. It begins by discussing storage media such as CDs, DVDs, tapes, and solid state storage. It then poses questions about why operating systems should be studied and some benefits of doing so. Specifically, it notes that operating systems are large, complex software that manages hardware resources and concurrency. The document also discusses why operating systems will not go away due to their fundamental role in making hardware useful. It provides an overview of the capstone operating systems course and focuses on design and implementation challenges. Finally, it covers some administrative details of the course.

Deadlock_SVVSDM_DWD
Deadlock_SVVSDM_DWDDeadlock_SVVSDM_DWD
Deadlock_SVVSDM_DWD

The document discusses deadlocks in operating systems. It begins by providing examples of deadlock situations and defining the four conditions required for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. It then describes methods for handling deadlocks, including deadlock prevention, avoidance, detection, and recovery. For prevention and avoidance, it discusses specific algorithms like the banking algorithm and resource allocation graphs. The document provides examples and diagrams to illustrate deadlock states and algorithms.

deadlockos
Resource-Allocation Graph AlgorithmResource-Allocation Graph Algorithm
Suppose that process Pi requests a resource Rj
The request can be granted only if converting the
request edge to an assignment edge does not result
in the formation of a cycle in the resource allocation
graph
Banker’s AlgorithmBanker’s Algorithm
Used when there exists multiple instances of a resource type
Each process must a priori claim maximum use
When a process requests a resource, it may have to wait
When a process gets all its resources, it must return them in a finite
amount of time
Data Structures for the Banker’sData Structures for the Banker’s
AlgorithmAlgorithm
Available: Vector of length m. If available [j] = k, there are k
instances of resource type Rj available.
Max: n x m matrix. If Max [i,j] = k, then process Pi may request at most
k instances of resource type Rj.
Allocation: n x m matrix. If Allocation[i,j] = k then Pi is currently
allocated k instances of Rj.
Need: n x m matrix. If Need[i,j] = k, then Pi may need k more
instances of Rj to complete its task.
Need [i,j] = Max[i,j] – Allocation [i,j]
Let n = number of processes, and m = number of resources types.
7.6 Deadlock Detection7.6 Deadlock Detection

Recommended for you

Lecture5
Lecture5Lecture5
Lecture5

This document discusses concurrency and deadlocks in operating systems. It describes how processes compete for limited resources which can result in deadlocks where a set of processes are permanently blocked waiting for each other's resources. There are four conditions required for deadlock: mutual exclusion, hold and wait, no preemption, and circular wait. Systems address deadlocks through prevention, avoidance, and detection techniques. Prevention excludes deadlock by design, avoidance dynamically allocates resources to avoid unsafe states, and detection identifies deadlocks to recover processes.

 
by jntu
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper

The document contains an exam for an Operating Systems course, including: 1) A 10 question short answer section covering topics like the main functions of an OS, multiprogramming, threads, deadlocks, dynamic linking, paging, interrupts vs traps, system programs, and dispatchers. 2) A longer answer section with 4 questions, including questions on batch processing systems, scheduling queues/algorithms, analyzing turnaround and waiting times for different scheduling algorithms, the dining philosophers problem and deadlocks, page sizes and addresses, thrashing prevention, file operations, OS security threats, and data encryption. The exam tests students' understanding of fundamental OS concepts through definitions, explanations of concepts, analyzing examples, and

Operating System: Deadlock
Operating System: DeadlockOperating System: Deadlock
Operating System: Deadlock

Deadlock is a very important topic in operating system. In this presentation slide, try to relate deadlock with real life scenario and find out some solution with two main algorithm- Safety and Banker's Algorithm.

deadlockoperating system presentationbanker's algorithm
Deadlock DetectionDeadlock Detection
For deadlock detection, the system must provide
An algorithm that examines the state of the system to detect whether a
deadlock has occurred
And an algorithm to recover from the deadlock
A detection-and-recovery scheme requires various kinds of overhead
Run-time costs of maintaining necessary information and executing the
detection algorithm
Potential losses inherent in recovering from a deadlock
Single Instance of Each ResourceSingle Instance of Each Resource
TypeType
Requires the creation and maintenance of a wait-for graph
Consists of a variant of the resource-allocation graph
The graph is obtained by removing the resource nodes from
a resource-allocation graph and collapsing the appropriate
edges
Consequently; all nodes are processes
Pi → Pj if Pi is waiting for Pj.
Periodically invoke an algorithm that searches for a cycle in
the graph
If there is a cycle, there exists a deadlock
An algorithm to detect a cycle in a graph requires an order of
n2
operations, where n is the number of vertices in the graph
Resource-Allocation Graph and Wait-forResource-Allocation Graph and Wait-for
GraphGraph
Resource-Allocation Graph Corresponding wait-for graph
Multiple Instances of a ResourceMultiple Instances of a Resource
TypeType
Available: A vector of length m indicates the number of
available resources of each type.
Allocation: An n x m matrix defines the number of
resources of each type currently allocated to each process.
Request: An n x m matrix indicates the current request of
each process. If Request [ij] = k, then process Pi is requesting
k more instances of resource type. Rj.
Required data structures:

Recommended for you

Holography
HolographyHolography
Holography

This document discusses the history and applications of 3D holographic technology. It begins by explaining that 3D technology has existed since the 1830s with the invention of stereoscopic photography. Different types of 3D glasses are described that allow the illusion of 3D to be viewed. The document outlines key milestones in the development of holography, from its discovery in 1947 to its use in various applications today such as movies, advertising, gaming, education and more. The future potential of holographic technology is envisioned, including uses in education, medicine and everyday devices.

Extreme semaphore 12 pax id290
Extreme semaphore 12 pax id290Extreme semaphore 12 pax id290
Extreme semaphore 12 pax id290

The villa Extreme Semaphore is a newly constructed minimalist villa located 5 minutes from beaches in Ibiza, Spain. It can sleep up to 12 people across 5 bedrooms, each with countryside views. Features include an open plan living and dining area, modern kitchen, master bedroom with sea views, 25m swimming pool, and furnished outdoor spaces. Rates are available upon request and the villa offers tailored hospitality services for clients.

Handling data 1
Handling data 1Handling data 1
Handling data 1

This document discusses different ways to display quantitative and qualitative data, including stem and leaf diagrams, bar charts, pie charts, and pictograms. It provides instructions on how to create stem and leaf diagrams and pie charts. Quantitative data can be discrete (counted) or continuous (measured) and qualitative data describes characteristics. Examples are given of quantitative and qualitative data.

statisticsmathsgcse
Detection-Algorithm UsageDetection-Algorithm Usage
When, and how often, to invoke the detection algorithm depends on:
How often is a deadlock likely to occur?
How many processes will be affected by deadlock when it happens?
If the detection algorithm is invoked arbitrarily, there may be many
cycles in the resource graph and so we would not be able to tell which
one of the many deadlocked processes “caused” the deadlock
If the detection algorithm is invoked for every resource request, such an
action will incur a considerable overhead in computation time
A less expensive alternative is to invoke the algorithm when CPU
utilization drops below 40%, for example
This is based on the observation that a deadlock eventually cripples system
throughput and causes CPU utilization to drop
7.7 Recovery From Deadlock7.7 Recovery From Deadlock
Recovery from DeadlockRecovery from Deadlock
Two Approaches
Process termination
Resource preemption
Recovery from Deadlock:Recovery from Deadlock: Process TerminationProcess Termination
Abort all deadlocked processes
This approach will break the deadlock, but at great expense
Abort one process at a time until the deadlock cycle is
eliminated
This approach incurs considerable overhead, since, after each process is
aborted, a deadlock-detection algorithm must be re-invoked to determine
whether any processes are still deadlocked
Many factors may affect which process is chosen for
termination
What is the priority of the process?
How long has the process run so far and how much longer will the process
need to run before completing its task?
How many and what type of resources has the process used?
How many more resources does the process need in order to finish its task?
How many processes will need to be terminated?
Is the process interactive or batch?

Recommended for you

Os Question Bank
Os Question BankOs Question Bank
Os Question Bank

This document contains a question bank on various topics in operating systems including: 1. Process synchronization questions focusing on critical section problems, semaphores, and solutions for two processes. 2. Memory management questions on paging and segmentation. 3. Deadlock questions on safe/unsafe states, bankers algorithm, prevention/avoidance strategies, and recovery from deadlocks. 4. CPU scheduling questions on algorithms like FCFS, RR, SJF and characteristics like short term, long term and medium term schedulers. 5. Process management questions on states, control blocks, creation/termination, and interprocess communication. The questions provided are meant to help students study notes

operating system
Semaphores
SemaphoresSemaphores
Semaphores

1) A semaphore consists of a counter, a waiting list, and wait() and signal() methods. Wait() decrements the counter and blocks if it becomes negative, while signal() increments the counter and resumes a blocked process if the counter becomes positive. 2) The dining philosophers problem is solved using semaphores to lock access to shared chopsticks, with one philosopher designated as a "weirdo" to avoid deadlock by acquiring locks in a different order. 3) The producer-consumer problem uses three semaphores - one to limit buffer size, one for empty slots, and one for locks - to coordinate producers adding to a bounded buffer

ossemaphoresoperating system
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors

The document summarizes key concepts in process synchronization and concurrency control, including: 1) Process synchronization techniques like semaphores, monitors, and atomic transactions that ensure orderly access to shared resources. Semaphores use wait() and signal() operations while monitors provide mutual exclusion through condition variables. 2) Concurrency control algorithms like locking and two-phase locking that ensure serializability of concurrent transactions accessing a database. Locking associates locks with data items to control concurrent access. 3) Challenges in concurrency control like deadlocks, priority inversion, and starvation that synchronization mechanisms aim to prevent. Log-based recovery with write-ahead logging and checkpoints is used to ensure atomicity of transactions in

Recovery from Deadlock:Recovery from Deadlock: ResourceResource
PreemptionPreemption
With this approach, we successively preempt some resources from
processes and give these resources to other processes until the
deadlock cycle is broken
When preemption is required to deal with deadlocks, then three
issues need to be addressed:
Selecting a victim – Which resources and which processes are to be
preempted?
Rollback – If we preempt a resource from a process, what should be
done with that process?
Starvation – How do we ensure that starvation will not occur? That is,
how can we guarantee that resources will not always be preempted
from the same process?
SummarySummary
Four necessary conditions must hold in the system for a deadlock
to occur
Mutual exclusion
Hold and wait
No preemption
Circular wait
Four principal methods for dealing with deadlocks
Use some protocol to (1) prevent or (2) avoid deadlocks, ensuring
that the system will never enter a deadlock state
Allow the system to enter a deadlock state, (3) detect it, and then
recover
 Recover by process termination or resource preemption
(4) Do nothing; ignore the problem altogether and pretend that
deadlocks never occur in the system (used by Windows and Unix)
To prevent deadlocks, we can ensure that at least one of the four
necessary conditions never holds
REFRENCESREFRENCES
Operating System Concepts – 9th
Edition By Silberchatz, Galvin and
Gagne

More Related Content

What's hot

Deadlock
DeadlockDeadlock
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
lalithambiga kamaraj
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
ushabarad142
 
Operating system Dead lock
Operating system Dead lockOperating system Dead lock
Operating system Dead lock
Karam Munir Butt
 
Operating System Deadlock Galvin
Operating System  Deadlock GalvinOperating System  Deadlock Galvin
Operating System Deadlock Galvin
Sonali Chauhan
 
Deadlock
DeadlockDeadlock
Deadlock
VISHAL DONGA
 
Deadlocks
Deadlocks Deadlocks
Deadlocks
Shijin Raj P
 
Gp1242 007 oer ppt
Gp1242 007 oer pptGp1242 007 oer ppt
Gp1242 007 oer ppt
Nivedita Kasturi
 
Chapter 7 - Deadlocks
Chapter 7 - DeadlocksChapter 7 - Deadlocks
Chapter 7 - Deadlocks
Wayne Jones Jnr
 
Deadlock detection & prevention
Deadlock detection & preventionDeadlock detection & prevention
Deadlock detection & prevention
IkhtiarUddinShaHin
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
AUST
 
Deadlock Avoidance in Operating System
Deadlock Avoidance in Operating SystemDeadlock Avoidance in Operating System
Deadlock Avoidance in Operating System
Mohammad Hafiz-Al-Masud
 
Operating system - Deadlock
Operating system - DeadlockOperating system - Deadlock
Operating system - Deadlock
Shashank Yenurkar
 
Deadlock avoidance and prevention .. computer networking
Deadlock avoidance and prevention .. computer networkingDeadlock avoidance and prevention .. computer networking
Deadlock avoidance and prevention .. computer networking
TamannaSharma70
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
Sara Ali
 
Deadlock- Operating System
Deadlock- Operating SystemDeadlock- Operating System
Deadlock- Operating System
Rajan Shah
 
Ch8
Ch8Ch8
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURYdeadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
अनिकेत चौधरी
 
Methods for handling deadlocks
Methods for handling deadlocksMethods for handling deadlocks
Methods for handling deadlocks
A. S. M. Shafi
 
Deadlock Presentation
Deadlock PresentationDeadlock Presentation
Deadlock Presentation
salmancreation
 

What's hot (20)

Deadlock
DeadlockDeadlock
Deadlock
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Operating system Dead lock
Operating system Dead lockOperating system Dead lock
Operating system Dead lock
 
Operating System Deadlock Galvin
Operating System  Deadlock GalvinOperating System  Deadlock Galvin
Operating System Deadlock Galvin
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlocks
Deadlocks Deadlocks
Deadlocks
 
Gp1242 007 oer ppt
Gp1242 007 oer pptGp1242 007 oer ppt
Gp1242 007 oer ppt
 
Chapter 7 - Deadlocks
Chapter 7 - DeadlocksChapter 7 - Deadlocks
Chapter 7 - Deadlocks
 
Deadlock detection & prevention
Deadlock detection & preventionDeadlock detection & prevention
Deadlock detection & prevention
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
 
Deadlock Avoidance in Operating System
Deadlock Avoidance in Operating SystemDeadlock Avoidance in Operating System
Deadlock Avoidance in Operating System
 
Operating system - Deadlock
Operating system - DeadlockOperating system - Deadlock
Operating system - Deadlock
 
Deadlock avoidance and prevention .. computer networking
Deadlock avoidance and prevention .. computer networkingDeadlock avoidance and prevention .. computer networking
Deadlock avoidance and prevention .. computer networking
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Deadlock- Operating System
Deadlock- Operating SystemDeadlock- Operating System
Deadlock- Operating System
 
Ch8
Ch8Ch8
Ch8
 
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURYdeadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
 
Methods for handling deadlocks
Methods for handling deadlocksMethods for handling deadlocks
Methods for handling deadlocks
 
Deadlock Presentation
Deadlock PresentationDeadlock Presentation
Deadlock Presentation
 

Viewers also liked

Banker's note - Blackstone Synergy Pitch
Banker's note - Blackstone Synergy PitchBanker's note - Blackstone Synergy Pitch
Banker's note - Blackstone Synergy Pitch
Debashish Banerjee
 
Bankers
BankersBankers
Introduction to Operating system
Introduction to Operating systemIntroduction to Operating system
Introduction to Operating system
Muhammad Aqeel
 
Deadlock_SVVSDM_DWD
Deadlock_SVVSDM_DWDDeadlock_SVVSDM_DWD
Deadlock_SVVSDM_DWD
Shivashekharayya Viraktamath
 
Lecture5
Lecture5Lecture5
Lecture5
jntu
 
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
Monica Sabharwal
 
Operating System: Deadlock
Operating System: DeadlockOperating System: Deadlock
Operating System: Deadlock
InteX Research Lab
 
Holography
HolographyHolography
Holography
mandeep kaur virk
 
Extreme semaphore 12 pax id290
Extreme semaphore 12 pax id290Extreme semaphore 12 pax id290
Extreme semaphore 12 pax id290
STRiVER P.M.C.
 
Handling data 1
Handling data 1Handling data 1
Handling data 1
Steve Bishop
 
Os Question Bank
Os Question BankOs Question Bank
Os Question Bank
Sonali Chauhan
 
Semaphores
SemaphoresSemaphores
Semaphores
Mohd Arif
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
sgpraju
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
Sweetestangel Kochar
 

Viewers also liked (14)

Banker's note - Blackstone Synergy Pitch
Banker's note - Blackstone Synergy PitchBanker's note - Blackstone Synergy Pitch
Banker's note - Blackstone Synergy Pitch
 
Bankers
BankersBankers
Bankers
 
Introduction to Operating system
Introduction to Operating systemIntroduction to Operating system
Introduction to Operating system
 
Deadlock_SVVSDM_DWD
Deadlock_SVVSDM_DWDDeadlock_SVVSDM_DWD
Deadlock_SVVSDM_DWD
 
Lecture5
Lecture5Lecture5
Lecture5
 
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
2009 Punjab Technical University B.C.A OPERATING SYSTEM Question paper
 
Operating System: Deadlock
Operating System: DeadlockOperating System: Deadlock
Operating System: Deadlock
 
Holography
HolographyHolography
Holography
 
Extreme semaphore 12 pax id290
Extreme semaphore 12 pax id290Extreme semaphore 12 pax id290
Extreme semaphore 12 pax id290
 
Handling data 1
Handling data 1Handling data 1
Handling data 1
 
Os Question Bank
Os Question BankOs Question Bank
Os Question Bank
 
Semaphores
SemaphoresSemaphores
Semaphores
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 

Similar to Mca ii os u-3 dead lock & io systems

Operating System
Operating SystemOperating System
Operating System
Subhasis Dash
 
CH07.pdf
CH07.pdfCH07.pdf
CH07.pdf
ImranKhan880955
 
Ch8 OS
Ch8 OSCh8 OS
Ch8 OS
C.U
 
Ice
IceIce
Module-2Deadlock.ppt
Module-2Deadlock.pptModule-2Deadlock.ppt
Module-2Deadlock.ppt
KAnurag2
 
Chapter 5(five).pdf
Chapter 5(five).pdfChapter 5(five).pdf
Chapter 5(five).pdf
amanuel236786
 
OS_Ch8
OS_Ch8OS_Ch8
OSCh8
OSCh8OSCh8
7.Dead Locks
7.Dead Locks7.Dead Locks
7.Dead Locks
Senthil Kanth
 
Methods for handling deadlock
Methods for handling deadlockMethods for handling deadlock
Methods for handling deadlock
sangrampatil81
 
OSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptxOSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptx
ssusere16bd9
 
Mch7 deadlock
Mch7 deadlockMch7 deadlock
Mch7 deadlock
wahab13
 
Deadlock.ppt
Deadlock.pptDeadlock.ppt
Deadlock.ppt
JeelBhanderi4
 
Deadlock
DeadlockDeadlock
Deadlock
Rajandeep Gill
 
Sucet os module_3_notes
Sucet os module_3_notesSucet os module_3_notes
Sucet os module_3_notes
SRINIVASUNIVERSITYEN
 
Deadlock
DeadlockDeadlock
Deadlock
Abhinaw Rai
 
Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
Gichelle Amon
 
Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232
marangburu42
 
Ch07 deadlocks
Ch07 deadlocksCh07 deadlocks
Ch07 deadlocks
Nazir Ahmed
 
Module 3 Deadlocks.pptx
Module 3 Deadlocks.pptxModule 3 Deadlocks.pptx
Module 3 Deadlocks.pptx
shreesha16
 

Similar to Mca ii os u-3 dead lock & io systems (20)

Operating System
Operating SystemOperating System
Operating System
 
CH07.pdf
CH07.pdfCH07.pdf
CH07.pdf
 
Ch8 OS
Ch8 OSCh8 OS
Ch8 OS
 
Ice
IceIce
Ice
 
Module-2Deadlock.ppt
Module-2Deadlock.pptModule-2Deadlock.ppt
Module-2Deadlock.ppt
 
Chapter 5(five).pdf
Chapter 5(five).pdfChapter 5(five).pdf
Chapter 5(five).pdf
 
OS_Ch8
OS_Ch8OS_Ch8
OS_Ch8
 
OSCh8
OSCh8OSCh8
OSCh8
 
7.Dead Locks
7.Dead Locks7.Dead Locks
7.Dead Locks
 
Methods for handling deadlock
Methods for handling deadlockMethods for handling deadlock
Methods for handling deadlock
 
OSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptxOSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptx
 
Mch7 deadlock
Mch7 deadlockMch7 deadlock
Mch7 deadlock
 
Deadlock.ppt
Deadlock.pptDeadlock.ppt
Deadlock.ppt
 
Deadlock
DeadlockDeadlock
Deadlock
 
Sucet os module_3_notes
Sucet os module_3_notesSucet os module_3_notes
Sucet os module_3_notes
 
Deadlock
DeadlockDeadlock
Deadlock
 
Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
 
Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232Deadlocks 160928121516-160928183232
Deadlocks 160928121516-160928183232
 
Ch07 deadlocks
Ch07 deadlocksCh07 deadlocks
Ch07 deadlocks
 
Module 3 Deadlocks.pptx
Module 3 Deadlocks.pptxModule 3 Deadlocks.pptx
Module 3 Deadlocks.pptx
 

More from Rai University

Brochure Rai University
Brochure Rai University Brochure Rai University
Brochure Rai University
Rai University
 
Mm unit 4point2
Mm unit 4point2Mm unit 4point2
Mm unit 4point2
Rai University
 
Mm unit 4point1
Mm unit 4point1Mm unit 4point1
Mm unit 4point1
Rai University
 
Mm unit 4point3
Mm unit 4point3Mm unit 4point3
Mm unit 4point3
Rai University
 
Mm unit 3point2
Mm unit 3point2Mm unit 3point2
Mm unit 3point2
Rai University
 
Mm unit 3point1
Mm unit 3point1Mm unit 3point1
Mm unit 3point1
Rai University
 
Mm unit 2point2
Mm unit 2point2Mm unit 2point2
Mm unit 2point2
Rai University
 
Mm unit 2 point 1
Mm unit 2 point 1Mm unit 2 point 1
Mm unit 2 point 1
Rai University
 
Mm unit 1point3
Mm unit 1point3Mm unit 1point3
Mm unit 1point3
Rai University
 
Mm unit 1point2
Mm unit 1point2Mm unit 1point2
Mm unit 1point2
Rai University
 
Mm unit 1point1
Mm unit 1point1Mm unit 1point1
Mm unit 1point1
Rai University
 
Bdft ii, tmt, unit-iii, dyeing & types of dyeing,
Bdft ii, tmt, unit-iii,  dyeing & types of dyeing,Bdft ii, tmt, unit-iii,  dyeing & types of dyeing,
Bdft ii, tmt, unit-iii, dyeing & types of dyeing,
Rai University
 
Bsc agri 2 pae u-4.4 publicrevenue-presentation-130208082149-phpapp02
Bsc agri  2 pae  u-4.4 publicrevenue-presentation-130208082149-phpapp02Bsc agri  2 pae  u-4.4 publicrevenue-presentation-130208082149-phpapp02
Bsc agri 2 pae u-4.4 publicrevenue-presentation-130208082149-phpapp02
Rai University
 
Bsc agri 2 pae u-4.3 public expenditure
Bsc agri  2 pae  u-4.3 public expenditureBsc agri  2 pae  u-4.3 public expenditure
Bsc agri 2 pae u-4.3 public expenditure
Rai University
 
Bsc agri 2 pae u-4.2 public finance
Bsc agri  2 pae  u-4.2 public financeBsc agri  2 pae  u-4.2 public finance
Bsc agri 2 pae u-4.2 public finance
Rai University
 
Bsc agri 2 pae u-4.1 introduction
Bsc agri  2 pae  u-4.1 introductionBsc agri  2 pae  u-4.1 introduction
Bsc agri 2 pae u-4.1 introduction
Rai University
 
Bsc agri 2 pae u-3.3 inflation
Bsc agri  2 pae  u-3.3  inflationBsc agri  2 pae  u-3.3  inflation
Bsc agri 2 pae u-3.3 inflation
Rai University
 
Bsc agri 2 pae u-3.2 introduction to macro economics
Bsc agri  2 pae  u-3.2 introduction to macro economicsBsc agri  2 pae  u-3.2 introduction to macro economics
Bsc agri 2 pae u-3.2 introduction to macro economics
Rai University
 
Bsc agri 2 pae u-3.1 marketstructure
Bsc agri  2 pae  u-3.1 marketstructureBsc agri  2 pae  u-3.1 marketstructure
Bsc agri 2 pae u-3.1 marketstructure
Rai University
 
Bsc agri 2 pae u-3 perfect-competition
Bsc agri  2 pae  u-3 perfect-competitionBsc agri  2 pae  u-3 perfect-competition
Bsc agri 2 pae u-3 perfect-competition
Rai University
 

More from Rai University (20)

Brochure Rai University
Brochure Rai University Brochure Rai University
Brochure Rai University
 
Mm unit 4point2
Mm unit 4point2Mm unit 4point2
Mm unit 4point2
 
Mm unit 4point1
Mm unit 4point1Mm unit 4point1
Mm unit 4point1
 
Mm unit 4point3
Mm unit 4point3Mm unit 4point3
Mm unit 4point3
 
Mm unit 3point2
Mm unit 3point2Mm unit 3point2
Mm unit 3point2
 
Mm unit 3point1
Mm unit 3point1Mm unit 3point1
Mm unit 3point1
 
Mm unit 2point2
Mm unit 2point2Mm unit 2point2
Mm unit 2point2
 
Mm unit 2 point 1
Mm unit 2 point 1Mm unit 2 point 1
Mm unit 2 point 1
 
Mm unit 1point3
Mm unit 1point3Mm unit 1point3
Mm unit 1point3
 
Mm unit 1point2
Mm unit 1point2Mm unit 1point2
Mm unit 1point2
 
Mm unit 1point1
Mm unit 1point1Mm unit 1point1
Mm unit 1point1
 
Bdft ii, tmt, unit-iii, dyeing & types of dyeing,
Bdft ii, tmt, unit-iii,  dyeing & types of dyeing,Bdft ii, tmt, unit-iii,  dyeing & types of dyeing,
Bdft ii, tmt, unit-iii, dyeing & types of dyeing,
 
Bsc agri 2 pae u-4.4 publicrevenue-presentation-130208082149-phpapp02
Bsc agri  2 pae  u-4.4 publicrevenue-presentation-130208082149-phpapp02Bsc agri  2 pae  u-4.4 publicrevenue-presentation-130208082149-phpapp02
Bsc agri 2 pae u-4.4 publicrevenue-presentation-130208082149-phpapp02
 
Bsc agri 2 pae u-4.3 public expenditure
Bsc agri  2 pae  u-4.3 public expenditureBsc agri  2 pae  u-4.3 public expenditure
Bsc agri 2 pae u-4.3 public expenditure
 
Bsc agri 2 pae u-4.2 public finance
Bsc agri  2 pae  u-4.2 public financeBsc agri  2 pae  u-4.2 public finance
Bsc agri 2 pae u-4.2 public finance
 
Bsc agri 2 pae u-4.1 introduction
Bsc agri  2 pae  u-4.1 introductionBsc agri  2 pae  u-4.1 introduction
Bsc agri 2 pae u-4.1 introduction
 
Bsc agri 2 pae u-3.3 inflation
Bsc agri  2 pae  u-3.3  inflationBsc agri  2 pae  u-3.3  inflation
Bsc agri 2 pae u-3.3 inflation
 
Bsc agri 2 pae u-3.2 introduction to macro economics
Bsc agri  2 pae  u-3.2 introduction to macro economicsBsc agri  2 pae  u-3.2 introduction to macro economics
Bsc agri 2 pae u-3.2 introduction to macro economics
 
Bsc agri 2 pae u-3.1 marketstructure
Bsc agri  2 pae  u-3.1 marketstructureBsc agri  2 pae  u-3.1 marketstructure
Bsc agri 2 pae u-3.1 marketstructure
 
Bsc agri 2 pae u-3 perfect-competition
Bsc agri  2 pae  u-3 perfect-competitionBsc agri  2 pae  u-3 perfect-competition
Bsc agri 2 pae u-3 perfect-competition
 

Recently uploaded

eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
siemaillard
 
AI_in_HR_Presentation Part 1 2024 0703.pdf
AI_in_HR_Presentation Part 1 2024 0703.pdfAI_in_HR_Presentation Part 1 2024 0703.pdf
AI_in_HR_Presentation Part 1 2024 0703.pdf
SrimanigandanMadurai
 
Bedok NEWater Photostory - COM322 Assessment (Story 2)
Bedok NEWater Photostory - COM322 Assessment (Story 2)Bedok NEWater Photostory - COM322 Assessment (Story 2)
Bedok NEWater Photostory - COM322 Assessment (Story 2)
Liyana Rozaini
 
Views in Odoo - Advanced Views - Pivot View in Odoo 17
Views in Odoo - Advanced Views - Pivot View in Odoo 17Views in Odoo - Advanced Views - Pivot View in Odoo 17
Views in Odoo - Advanced Views - Pivot View in Odoo 17
Celine George
 
Principles of Roods Approach!!!!!!!.pptx
Principles of Roods Approach!!!!!!!.pptxPrinciples of Roods Approach!!!!!!!.pptx
Principles of Roods Approach!!!!!!!.pptx
ibtesaam huma
 
2024 KWL Back 2 School Summer Conference
2024 KWL Back 2 School Summer Conference2024 KWL Back 2 School Summer Conference
2024 KWL Back 2 School Summer Conference
KlettWorldLanguages
 
NLC Grade 3.................................... ppt.pptx
NLC Grade 3.................................... ppt.pptxNLC Grade 3.................................... ppt.pptx
NLC Grade 3.................................... ppt.pptx
MichelleDeLaCruz93
 
NationalLearningCamp-2024-Orientation-for-RO-SDO.pptx
NationalLearningCamp-2024-Orientation-for-RO-SDO.pptxNationalLearningCamp-2024-Orientation-for-RO-SDO.pptx
NationalLearningCamp-2024-Orientation-for-RO-SDO.pptx
CelestineMiranda
 
How to Show Sample Data in Tree and Kanban View in Odoo 17
How to Show Sample Data in Tree and Kanban View in Odoo 17How to Show Sample Data in Tree and Kanban View in Odoo 17
How to Show Sample Data in Tree and Kanban View in Odoo 17
Celine George
 
How to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 WebsiteHow to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 Website
Celine George
 
Lecture_Notes_Unit4_Chapter_8_9_10_RDBMS for the students affiliated by alaga...
Lecture_Notes_Unit4_Chapter_8_9_10_RDBMS for the students affiliated by alaga...Lecture_Notes_Unit4_Chapter_8_9_10_RDBMS for the students affiliated by alaga...
Lecture_Notes_Unit4_Chapter_8_9_10_RDBMS for the students affiliated by alaga...
Murugan Solaiyappan
 
How to Install Theme in the Odoo 17 ERP
How to  Install Theme in the Odoo 17 ERPHow to  Install Theme in the Odoo 17 ERP
How to Install Theme in the Odoo 17 ERP
Celine George
 
Webinar Innovative assessments for SOcial Emotional Skills
Webinar Innovative assessments for SOcial Emotional SkillsWebinar Innovative assessments for SOcial Emotional Skills
Webinar Innovative assessments for SOcial Emotional Skills
EduSkills OECD
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
heathfieldcps1
 
Final_SD_Session3_Ferriols, Ador Dionisio, Fajardo.pptx
Final_SD_Session3_Ferriols, Ador Dionisio, Fajardo.pptxFinal_SD_Session3_Ferriols, Ador Dionisio, Fajardo.pptx
Final_SD_Session3_Ferriols, Ador Dionisio, Fajardo.pptx
shimeathdelrosario1
 
BRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptx
BRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptxBRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptx
BRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptx
kambal1234567890
 
Credit limit improvement system in odoo 17
Credit limit improvement system in odoo 17Credit limit improvement system in odoo 17
Credit limit improvement system in odoo 17
Celine George
 
The membership Module in the Odoo 17 ERP
The membership Module in the Odoo 17 ERPThe membership Module in the Odoo 17 ERP
The membership Module in the Odoo 17 ERP
Celine George
 
Conducting exciting academic research in Computer Science
Conducting exciting academic research in Computer ScienceConducting exciting academic research in Computer Science
Conducting exciting academic research in Computer Science
Abhik Roychoudhury
 

Recently uploaded (20)

eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
 
AI_in_HR_Presentation Part 1 2024 0703.pdf
AI_in_HR_Presentation Part 1 2024 0703.pdfAI_in_HR_Presentation Part 1 2024 0703.pdf
AI_in_HR_Presentation Part 1 2024 0703.pdf
 
Bedok NEWater Photostory - COM322 Assessment (Story 2)
Bedok NEWater Photostory - COM322 Assessment (Story 2)Bedok NEWater Photostory - COM322 Assessment (Story 2)
Bedok NEWater Photostory - COM322 Assessment (Story 2)
 
Views in Odoo - Advanced Views - Pivot View in Odoo 17
Views in Odoo - Advanced Views - Pivot View in Odoo 17Views in Odoo - Advanced Views - Pivot View in Odoo 17
Views in Odoo - Advanced Views - Pivot View in Odoo 17
 
Principles of Roods Approach!!!!!!!.pptx
Principles of Roods Approach!!!!!!!.pptxPrinciples of Roods Approach!!!!!!!.pptx
Principles of Roods Approach!!!!!!!.pptx
 
2024 KWL Back 2 School Summer Conference
2024 KWL Back 2 School Summer Conference2024 KWL Back 2 School Summer Conference
2024 KWL Back 2 School Summer Conference
 
NLC Grade 3.................................... ppt.pptx
NLC Grade 3.................................... ppt.pptxNLC Grade 3.................................... ppt.pptx
NLC Grade 3.................................... ppt.pptx
 
NationalLearningCamp-2024-Orientation-for-RO-SDO.pptx
NationalLearningCamp-2024-Orientation-for-RO-SDO.pptxNationalLearningCamp-2024-Orientation-for-RO-SDO.pptx
NationalLearningCamp-2024-Orientation-for-RO-SDO.pptx
 
How to Show Sample Data in Tree and Kanban View in Odoo 17
How to Show Sample Data in Tree and Kanban View in Odoo 17How to Show Sample Data in Tree and Kanban View in Odoo 17
How to Show Sample Data in Tree and Kanban View in Odoo 17
 
How to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 WebsiteHow to Store Data on the Odoo 17 Website
How to Store Data on the Odoo 17 Website
 
Lecture_Notes_Unit4_Chapter_8_9_10_RDBMS for the students affiliated by alaga...
Lecture_Notes_Unit4_Chapter_8_9_10_RDBMS for the students affiliated by alaga...Lecture_Notes_Unit4_Chapter_8_9_10_RDBMS for the students affiliated by alaga...
Lecture_Notes_Unit4_Chapter_8_9_10_RDBMS for the students affiliated by alaga...
 
How to Install Theme in the Odoo 17 ERP
How to  Install Theme in the Odoo 17 ERPHow to  Install Theme in the Odoo 17 ERP
How to Install Theme in the Odoo 17 ERP
 
Webinar Innovative assessments for SOcial Emotional Skills
Webinar Innovative assessments for SOcial Emotional SkillsWebinar Innovative assessments for SOcial Emotional Skills
Webinar Innovative assessments for SOcial Emotional Skills
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
 
Final_SD_Session3_Ferriols, Ador Dionisio, Fajardo.pptx
Final_SD_Session3_Ferriols, Ador Dionisio, Fajardo.pptxFinal_SD_Session3_Ferriols, Ador Dionisio, Fajardo.pptx
Final_SD_Session3_Ferriols, Ador Dionisio, Fajardo.pptx
 
BRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptx
BRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptxBRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptx
BRIGADA ESKWELA OPENING PROGRAM KICK OFF.pptx
 
“A NOSSA CA(U)SA”. .
“A NOSSA CA(U)SA”.                      .“A NOSSA CA(U)SA”.                      .
“A NOSSA CA(U)SA”. .
 
Credit limit improvement system in odoo 17
Credit limit improvement system in odoo 17Credit limit improvement system in odoo 17
Credit limit improvement system in odoo 17
 
The membership Module in the Odoo 17 ERP
The membership Module in the Odoo 17 ERPThe membership Module in the Odoo 17 ERP
The membership Module in the Odoo 17 ERP
 
Conducting exciting academic research in Computer Science
Conducting exciting academic research in Computer ScienceConducting exciting academic research in Computer Science
Conducting exciting academic research in Computer Science
 

Mca ii os u-3 dead lock & io systems

  • 1. UNIT 3: DEADLOCKUNIT 3: DEADLOCK MCA IIMCA II
  • 2. Chapter 7: DeadlocksChapter 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 from Deadlock
  • 3. Chapter ObjectivesChapter 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, avoiding, or detecting deadlocks in a computer system
  • 4. 7.1 System Model7.1 System Model
  • 5. The Deadlock ProblemThe Deadlock Problem A deadlock consists of a set of blocked processes, each holding a resource and waiting to acquire a resource held by another process in the set Example #1 A system has 2 disk drives P1 and P2 each hold one disk drive and each needs the other one Example #2 Semaphores A and B, initialized to 1 P0 P1 wait (A); wait(B) wait (B); wait(A)
  • 6. Bridge Crossing ExampleBridge Crossing Example Traffic only in one direction The resource is a one-lane bridge If a deadlock occurs, it can be resolved if one car backs up (preempt resources and rollback) Several cars may have to be backed up if a deadlock occurs Starvation is possible
  • 7. System ModelSystem Model Resource types R1, R2, . . ., Rm CPU cycles, memory space, I/O devices Each resource type Ri has 1 or moreinstances Each process utilizes a resource as follows: request use release
  • 8. 7.2 Deadlock Characterization7.2 Deadlock Characterization
  • 9. Deadlock CharacterizationDeadlock Characterization Mutual exclusion: only one process at a time can use a resource Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes No preemption: a resource can be released only voluntarily by the process holding it after that process has completed its task Circular wait: there exists a set {P0, P1, …, P0} of waiting processes such that P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that is held by P2, …, Pn–1 is waiting for a resource that is held by Pn, and Pn is waiting for a resource that is held by P0 Deadlock can arise if four conditions hold simultaneously.
  • 10. Resource-Allocation GraphResource-Allocation Graph V is partitioned into two types: P = {P1, P2, …, Pn}, the set consisting of all the processes in the system R = {R1, R2, …, Rm}, the set consisting of all resource types in the system request edge – directed edge P1 → Rj assignment edge – directed edge Rj → Pi A set of vertices V and a set of edges E.
  • 11. Resource-Allocation Graph (Cont.)Resource-Allocation Graph (Cont.) Process Resource Type with 4 instances Pi requests instance of Rj Pi is holding an instance of Rj Pi Pi Rj Rj
  • 12. Resource Allocation Graph With A DeadlockResource Allocation Graph With A Deadlock Before P3 requested an instance of R2 After P3 requested an instance of R2
  • 13. Graph With A Cycle But No DeadlockGraph With A Cycle But No Deadlock Process P4 may release its instance of resource type R2. That resource can then be allocated to P3, thereby breaking the cycle.
  • 14. Relationship of cycles to deadlocksRelationship of cycles to deadlocks If a resource allocation graph contains no cycles ⇒ no deadlock If a resource allocation graph contains a cycle and if only one instance exists per resource type ⇒ deadlock If a resource allocation graph contains a cycle and and if several instances exists per resource type ⇒ possibility of deadlock
  • 15. 7.3 Methods for Handling7.3 Methods for Handling DeadlocksDeadlocks
  • 16. Methods for Handling DeadlocksMethods for Handling Deadlocks Prevention Ensure that the system will never enter a deadlock state Avoidance Ensure that the system will never enter an unsafe state Detection Allow the system to enter a deadlock state and then recover Do Nothing Ignore the problem and let the user or system administrator respond to the problem; used by most operating systems, including Windows and UNIX
  • 17. 7.4 Deadlock Prevention7.4 Deadlock Prevention
  • 18. Deadlock PreventionDeadlock Prevention Mutual Exclusion – The mutual-exclusion condition must hold for non-sharable resources Hold and Wait – we must guarantee that whenever a process requests a resource, it does not hold any other resources Require a process to request and be allocated all its resources before it begins execution, or allow a process to request resources only when the process has none Result: Low resource utilization; starvation possible To prevent deadlock, we can restrain the ways that a request can be made
  • 19. Deadlock Prevention (Cont.)Deadlock Prevention (Cont.) 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 A process will be restarted only when it can regain its old resources, as well as the new ones that it is requesting Circular Wait – impose a total ordering of all resource types, and require that each process requests resources in an increasing order of enumeration. For example: F(tape drive) = 1 F(disk drive) = 5 F(printer) = 12
  • 20. 7.5 Deadlock Avoidance7.5 Deadlock Avoidance
  • 21. Deadlock AvoidanceDeadlock Avoidance Simplest and most useful model requires that each process declare the maximum number of resources of each type that it may need The deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that there can never be a circular-wait condition A resource-allocation state is defined by the number of available and allocated resources, and the maximum demands of the processes Requires that the system has some additional a priori information available. a priori: formed or conceived beforehand
  • 22. Safe StateSafe State When a process requests an available resource, the system must decide if immediate allocation leaves the system in a safe state A system is in a safe state only if there exists a safe sequence A sequence of processes <P1, P2, …, Pn> is a safe sequence for the current allocation state if, for each Pi, the resource requests that Pi can still make, can be satisfied by currently available resources plus resources held by all Pj, with j < i. That is: If the Pi resource needs are not immediately available, then Pi can wait until all Pj have finished When Pj is finished, Pi can obtain needed resources, execute, return allocated resources, and terminate When Pi terminates, Pi +1 can obtain its needed resources, and so on
  • 23. Safe State (continued)Safe State (continued) If a system is in safe state ⇒ no deadlocks If a system is in unsafe state ⇒ possibility of deadlock Avoidance ⇒ ensure that a system will never enter an unsafe state
  • 24. Safe, Unsafe , Deadlock StateSafe, Unsafe , Deadlock State
  • 25. Avoidance algorithmsAvoidance algorithms For a single instance of a resource type, use a resource- allocation graph For multiple instances of a resource type, use the banker’s algorithm
  • 26. Resource-Allocation Graph SchemeResource-Allocation Graph Scheme Introduce a new kind of edge called a claim edge Claim edge Pi Rj indicates that process Pj may request resource Rj; which is represented by a dashed line A claim edge converts to a request edge when a process requests a resource A request edge converts to an assignment edge when the resource is allocated to the process When a resource is released by a process, an assignment edge reconverts to a claim edge Resources must be claimed a priori in the system
  • 27. Resource-Allocation Graph withResource-Allocation Graph with Claim EdgesClaim Edges Request edge Assignment edge Claim edge Claim edge
  • 28. Unsafe State In Resource-Allocation GraphUnsafe State In Resource-Allocation Graph Assignment edge Request edge Assignment edgeClaim edge
  • 29. Resource-Allocation Graph AlgorithmResource-Allocation Graph Algorithm Suppose that process Pi requests a resource Rj The request can be granted only if converting the request edge to an assignment edge does not result in the formation of a cycle in the resource allocation graph
  • 30. Banker’s AlgorithmBanker’s Algorithm Used when there exists multiple instances of a resource type Each process must a priori claim maximum use When a process requests a resource, it may have to wait When a process gets all its resources, it must return them in a finite amount of time
  • 31. Data Structures for the Banker’sData Structures for the Banker’s AlgorithmAlgorithm Available: Vector of length m. If available [j] = k, there are k instances of resource type Rj available. Max: n x m matrix. If Max [i,j] = k, then process Pi may request at most k instances of resource type Rj. Allocation: n x m matrix. If Allocation[i,j] = k then Pi is currently allocated k instances of Rj. Need: n x m matrix. If Need[i,j] = k, then Pi may need k more instances of Rj to complete its task. Need [i,j] = Max[i,j] – Allocation [i,j] Let n = number of processes, and m = number of resources types.
  • 32. 7.6 Deadlock Detection7.6 Deadlock Detection
  • 33. Deadlock DetectionDeadlock Detection For deadlock detection, the system must provide An algorithm that examines the state of the system to detect whether a deadlock has occurred And an algorithm to recover from the deadlock A detection-and-recovery scheme requires various kinds of overhead Run-time costs of maintaining necessary information and executing the detection algorithm Potential losses inherent in recovering from a deadlock
  • 34. Single Instance of Each ResourceSingle Instance of Each Resource TypeType Requires the creation and maintenance of a wait-for graph Consists of a variant of the resource-allocation graph The graph is obtained by removing the resource nodes from a resource-allocation graph and collapsing the appropriate edges Consequently; all nodes are processes Pi → Pj if Pi is waiting for Pj. Periodically invoke an algorithm that searches for a cycle in the graph If there is a cycle, there exists a deadlock An algorithm to detect a cycle in a graph requires an order of n2 operations, where n is the number of vertices in the graph
  • 35. Resource-Allocation Graph and Wait-forResource-Allocation Graph and Wait-for GraphGraph Resource-Allocation Graph Corresponding wait-for graph
  • 36. Multiple Instances of a ResourceMultiple Instances of a Resource TypeType Available: A vector of length m indicates the number of available resources of each type. Allocation: An n x m matrix defines the number of resources of each type currently allocated to each process. Request: An n x m matrix indicates the current request of each process. If Request [ij] = k, then process Pi is requesting k more instances of resource type. Rj. Required data structures:
  • 37. Detection-Algorithm UsageDetection-Algorithm Usage When, and how often, to invoke the detection algorithm depends on: How often is a deadlock likely to occur? How many processes will be affected by deadlock when it happens? If the detection algorithm is invoked arbitrarily, there may be many cycles in the resource graph and so we would not be able to tell which one of the many deadlocked processes “caused” the deadlock If the detection algorithm is invoked for every resource request, such an action will incur a considerable overhead in computation time A less expensive alternative is to invoke the algorithm when CPU utilization drops below 40%, for example This is based on the observation that a deadlock eventually cripples system throughput and causes CPU utilization to drop
  • 38. 7.7 Recovery From Deadlock7.7 Recovery From Deadlock
  • 39. Recovery from DeadlockRecovery from Deadlock Two Approaches Process termination Resource preemption
  • 40. Recovery from Deadlock:Recovery from Deadlock: Process TerminationProcess Termination Abort all deadlocked processes This approach will break the deadlock, but at great expense Abort one process at a time until the deadlock cycle is eliminated This approach incurs considerable overhead, since, after each process is aborted, a deadlock-detection algorithm must be re-invoked to determine whether any processes are still deadlocked Many factors may affect which process is chosen for termination What is the priority of the process? How long has the process run so far and how much longer will the process need to run before completing its task? How many and what type of resources has the process used? How many more resources does the process need in order to finish its task? How many processes will need to be terminated? Is the process interactive or batch?
  • 41. Recovery from Deadlock:Recovery from Deadlock: ResourceResource PreemptionPreemption With this approach, we successively preempt some resources from processes and give these resources to other processes until the deadlock cycle is broken When preemption is required to deal with deadlocks, then three issues need to be addressed: Selecting a victim – Which resources and which processes are to be preempted? Rollback – If we preempt a resource from a process, what should be done with that process? Starvation – How do we ensure that starvation will not occur? That is, how can we guarantee that resources will not always be preempted from the same process?
  • 42. SummarySummary Four necessary conditions must hold in the system for a deadlock to occur Mutual exclusion Hold and wait No preemption Circular wait Four principal methods for dealing with deadlocks Use some protocol to (1) prevent or (2) avoid deadlocks, ensuring that the system will never enter a deadlock state Allow the system to enter a deadlock state, (3) detect it, and then recover  Recover by process termination or resource preemption (4) Do nothing; ignore the problem altogether and pretend that deadlocks never occur in the system (used by Windows and Unix) To prevent deadlocks, we can ensure that at least one of the four necessary conditions never holds
  • 43. REFRENCESREFRENCES Operating System Concepts – 9th Edition By Silberchatz, Galvin and Gagne