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

A Demonstration On: "Deadlocks"

A deadlock occurs when processes are waiting for resources held by other waiting processes, resulting in a cyclic dependency where no further progress can be made. The four necessary conditions for a deadlock are: mutual exclusion, hold and wait, no preemption, and circular wait. A resource allocation graph can model the allocation of resources to processes and detect if a deadlock cycle exists in the system.

Uploaded by

ks.ashwini
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
153 views

A Demonstration On: "Deadlocks"

A deadlock occurs when processes are waiting for resources held by other waiting processes, resulting in a cyclic dependency where no further progress can be made. The four necessary conditions for a deadlock are: mutual exclusion, hold and wait, no preemption, and circular wait. A resource allocation graph can model the allocation of resources to processes and detect if a deadlock cycle exists in the system.

Uploaded by

ks.ashwini
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 12

A

Demonstration on
“DEADLOCKS”

By
Ashwini K S
Contents
• What is a deadlock?
• Examples
• Necessary conditions
• Deadlock detection
What is a Deadlock?
• A Deadlock can be defined as a situation
in which the process are unknowingly
waiting for the resources which are never
available

• The cause of Deadlocks: Each process is


in the need of what another process has.
Examples
• You can't get a job without experience;
you can't get experience without a job.

• "It takes money to make money".

• Bridge crossing example


Continued…

• Each section of a bridge can be viewed as a


resource.
• 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.
Necessary conditions
• Mutual exclusion : One or more than one
resource must be held by a process in a
non sharable mode.

• Hold and wait : A process holds a


resource while waiting for another
resource.
Continued…
• No preemption : There is only voluntary
release of a resource- nobody else can
make a process give up a resource.

• Circular wait : Process A waits for Process


B waits for Process C and Process C waits
for Process A.

ALL of these four MUST hold good


simultaneously for a deadlock to occur.
Deadlock detection
• Resource Allocation Graph is a visual way to determine if
a deadlock has, or may occur.

G = ( V, E ) The graph contains nodes and edges.


 
V - Nodes consist of processes = { P1, P2, P3, ...} and
resource types { R1, R2, ...}
 
E - Edges are ( Pi, Rj ) or ( Ri, Pj )
 
Continued…
Pi Pi
Pi

Process Resource Request Allocation

An arrow from the process to resource indicates the


process is requesting the resource. An arrow from
resource to process shows an instance of the resource
has been allocated to the process.
 
Process is a circle, resource type is square; dots represent
number of instances of resource in type. Request points
to square, assignment comes from dot.
Continued…
• If the graph contains no cycles, then no process is deadlocked.
• If there is a cycle, then:
a) If resource types have multiple instances, then deadlock MAY exist.
b) If each resource type has 1 instance, then deadlock has occurred.

R3 Assigned to P3

Resource allocation graph

P2 Requests P3
Continued…
Resource allocation graph
Resource allocation graph with a cycle but no deadlock.
with a deadlock.

You might also like