You are on page 1of 11

Deadlock and Deadlock characterization

Seminar Presentation
Jain University
BCA A
2nd Semester

Proposed by:-
Lutfullah Haqnesare
Deadlock
• What is a deadlock?

• How does it occurs?

• What are the conditions


that force it to occur?

Hey!!!! I am not • Representation of


deadlock cycle in a
dead!!!!! graph.
The 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 are the process and each hold one D1 and D2 respectively
and each needs the other one for completion.

• Example #2
-- When two trains approach each other at a crossing,
both shall come to a full stop and neither shall start
up again until the other has gone.
More Examples
There are four trucks A,
B, C & D in a pattern
such that the trucks
moves only in forward
direction.
System Model

• For the purposes of deadlock discussion, a system can be modeled


as a collection of limited resources, which can be partitioned into
different categories, to be allocated to a number
of processes, each having different needs.
• Resource types R1, R2, . . ., Rm
CPU cycles, memory space, I/O devices

• Each resource type Ri has 1 or more instances


• -this picture represents a resource type Rj with 4 instances
• In normal operation a process must request a resource before
using it, and release it when it is done, in the following sequence:

– Request - If the request cannot be immediately granted, then the


process must wait until the resource(s) it needs become available.
For example the system calls open( ), malloc( ), new( ), and request( ).

– Use - The process uses the resource.


e.g. prints to the printer or reads from the file.

– Release - The process relinquishes the resource. so that it becomes


available for other processes.
For example, close( ), free( ), delete( ), and release( ).
Deadlock Characterization
Deadlock can arise if four conditions hold
simultaneously:
1 Condition
st 2nd Condition
Hold And Wait
Mutual Exclusion (Mutex)
- Requesting process hold already,
resources while waiting for
- The resources involved are
requested resources.
Eg:- suppose B has a copy and is
non-shareable.
waiting for a pen from A but A is also
waiting for his copy to be returned
from C so he can write. We can see
Eg:- suppose a pen is used by A, and that A is holding something which B
B wants to use the same pen, but as requires while A is waiting for
the pen is non-shareable B has to something it requires.
wait till A finished using it.
3rd Condition
4th Condition
Circular Wait
No Preemption • The processes in the system
•  Resources cannot be removed form a circular list or chain
from the processes using it, until where each process in the list
is waiting for a resource held by
the next process in the list.
process releases the resource
• Eg:- Process A waits for Process B
voluntarily or after completion.
waits for Process C .... waits for
Process A.
Eg:- while A is talking to someone from
his cell phone B can’t forcefully take the
phone until A finishes talking.
Resource-Allocation Graph
• Process

• Resource Type with 4 instances

• Pi requests instance of Rj
Pi
Rj

• Pi is holding an instance of Rj
Pi
Rj
Resource Allocation Graph With A Deadlock and Without A Deadlock

Here p3 is Here unlike


in free state the previous
and it graph p3 is
completes not in free
its execution state as it is
releasing the requesting r2
resource for resource
required for and a closed
p2. chain has
formed.
Graph Without Deadlock Graph With Deadlock
Queries?
Thanks for your support

You might also like