0% found this document useful (0 votes)
37 views

1 - 31 - July

Deadlocks occur when a set of blocked processes each hold resources and wait to acquire resources held by other processes in the set, resulting in an infinite wait. Deadlocks can be avoided by ensuring that at least one of four conditions for deadlock is not met: mutual exclusion of resources, holding and waiting, no preemption, and circular wait. Techniques for dealing with deadlocks include prevention, avoidance, detection, and ignorance. A resource allocation graph (RAG) models system resources and process usage, where a cycle in the graph indicates a potential deadlock.

Uploaded by

sam patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

1 - 31 - July

Deadlocks occur when a set of blocked processes each hold resources and wait to acquire resources held by other processes in the set, resulting in an infinite wait. Deadlocks can be avoided by ensuring that at least one of four conditions for deadlock is not met: mutual exclusion of resources, holding and waiting, no preemption, and circular wait. Techniques for dealing with deadlocks include prevention, avoidance, detection, and ignorance. A resource allocation graph (RAG) models system resources and process usage, where a cycle in the graph indicates a potential deadlock.

Uploaded by

sam patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Class 18

Deadlock
Deadlock Demonstrated
What is a deadlock?
Deadlocks are a set of blocked processes each holding a resource
and waiting to acquire a resource held by another process.
Deadlock is a common problem in multi-processing where several
processes share a specific type of mutually exclusive resource
known as a soft lock or software.
Deadlock vs Starvation
Deadlock Starvation
Deadlock is a situation where Starvation is a situation where
no process got blocked and no the low priority process got
process proceeds blocked and the high priority
processes proceed.
Deadlock is an infinite waiting. Starvation is a long waiting
but not infinite.
Every Deadlock is always a Every starvation need not be
starvation. deadlock.

The requested resource is The requested resource is


blocked by the other process. continuously be used by the
higher priority processes.
How to avoid Deadlocks
.Deadlocks can be avoided by avoiding at least one of the four conditions, because all this
four conditions are required simultaneously to cause deadlock.

 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, …, Pn} 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.
.
Dealing with Deadlock
.
Prevention

Avoidance

Detection

Ignorance
.
System Model
. System consists of resources
 Resource types R1, R2, . . ., Rm
CPU cycles, memory space, I/O devices
 Each resource type Ri has Wi instances.
 Each process utilizes a resource as follows:
 request
 use
 release
Resource-Allocation Graph
.A set of vertices V and a set of edges E

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 Pi  Rj

assignment edge – directed edge Rj  Pi


Resource-Allocation Graph
.
Process

Resource Type with 4 instances

Pi requests instance of Rj Pi

Pi is holding an instance of Rj Pi
Resource-Allocation Graph
.

Fig 1: RAG fig2 : RAG with Deadlock Fig 3: RAG without Deadlock
Conclusion
If graph contains no cycles  no deadlock
If graph contains a cycle 
◦ if only one instance per resource type, then deadlock
◦ if several instances per resource type, possibility of
deadlock
References
1. Silberschatz, Galvin, Gagne, Operating System Concepts: International Student
Version, 9th Edition, Paperback: 992 pages Publisher: Wiley; Eighth edition (20
April 2009) Paperback – 20 Apr 2009, Language: English, ISBN-10: 8126520515,
ISBN-13: 978-8126520510.

2. Tanenbaum, Modern Operating Systems, 4th Edition, Paperback: 1136 pages,


Publisher: Pearson Education India; Fourth edition (31 August 2016), Language:
English, ISBN-10: 9332575770, ISBN-13: 978-9332575776
Thank you

You might also like