A deadlock occurs in a concurrent system when two or more processes are unable to proceed because each is waiting for another to release a resource. This situation leads to a standstill where none of the processes can complete their execution.
2. WHAT IS DEADLOCK?
The set of processes are said to be in
deadlock state, if each
process in a set is holding some
resource and is waiting for the
resource that is held by another
process in a set.
3. EXAMPLES OF DEADLOCKS
A real-world example would be traffic,
which is going only in one direction. Here,
a bridge is considered a resource.
So, when Deadlock happens, it can be
easily resolved if one car backs up
(Preempt resources and rollback).
Several cars may have to be backed up if a
deadlock situation occurs
4. One more example
John and Amy are brother-sister. They both are in a deadlock state as Amy
wants a laptop which John is having and is not in the mood to give it to his
sister. And Amy has a TV remote which John wants, But Amy is not giving it to
him.
5. SYSTEM MODEL
• The Deadlock System model is a way to describe
and analyze systems that may be prone to
deadlocks, which occur when two or more
processes are unable to proceed because they are
each waiting for the other to release a resource.
• A system consists of a finite number of resources
to be distributed among a number of competing
processes
• A process must request a resource before using it
and must release the resource after using it. A
6. • Each process utilizes a resource as follows :
Request :- The process requests the resource. If the request
cannot be granted immediately (for example, if the resource is
being used by another process), then the requesting process
must wait until it can acquire the resource.
Use :- The process can operate on the resource (for example,
if the resource is a printer, the process can print on the
printer).
Release :- The process releases the resource.
• System consists of resources
• Resource types R1 , R2,....., RM
• Each resource type R1 has W1
instances.
7. DEADLOCK CHARACTERIZATION
A deadlock situation can arise if the following four
conditions hold simultaneously in a system
• Mutual exclusion : At least one resource must be held
in a non-sharable mode; that is, only one process at
a time can use the resource. If another process
requests that resource, the requesting process must
be delayed until the resource has been released.
8. • Hold and wait : A process must be holding at least
one resource and waiting to acquire additional
resources that are currently being held by other
processes.
• No preemption : Resources cannot be preempted;
that is, a resource can be released only voluntarily by
the process holding it, after that process has
completed its task.
9. • Circular wait : In the below figure there is P1 waiting for
P2 to release R2 , P2 is waiting for P3 to release R3 and
P3 is waiting for P1 to release R1 , this is known as
circular wait.
10. RESOURCE ALLOCATION GRAPH
• Deadlocks can be described more precisely in terms of a
directed graph called a system resource allocation graph. This
graph consists of a set of vertices V and a set of edges E.
• V is partitioned into two types:
• P = {P1 , P2 , …, P n }, the set consisting of all the
processes in the system
• R = {R1 , R2 , …, R m }, the set consisting of all resource
types in the system
• request edge – directed edge Pi → Rj
• assignment edge – directed edge Rj → Pi
11. The resource-allocation graph shown in Figure depicts
the following situation.
The sets P, R, and E:
• P = {P1, P2, P3}
• R = {R1, R2, R3, R4}
• E = {P1 → R1, P2 → R3, R1 → P2, R2 → P2, R2 → P1, R3
→P3}
Resource instances
• One instance of resource type R1
• Two instances of resource type R2
• One instance of resource type R3
• Three instances of resource type R4
Process states:
• Process P1 is holding an instance of resource type R2 and
is waiting for an instance of resource type R1.
• Process P2 is holding an instance of R1 and an instance of
R2 and is waiting for an instance of R3.
• Process P3 is holding an instance of R3.
12. After P3 requested an instance of
R2
12
Resource-allocation graph with a
deadlock.
Resource-allocation graph
with a cycle but no
deadlock
13. Relationship 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
14. Summary
• The presentation covered deadlocks, a critical issue in
computer systems:
• Deadlocks are situations where processes are stuck due to
resource conflicts.
• Key concepts include the system model, deadlock
characterization, and resource-allocation graphs.
• Understanding and managing deadlocks is crucial for
system reliability and performance