Professional Documents
Culture Documents
Eminar On: Deadlock in Operating System
Eminar On: Deadlock in Operating System
Eminar On: Deadlock in Operating System
2. USE :-
The process can operate only the resources.
3. RELEASE :-
The process release the release the resources.
DEADLOCK CHARACTERIZATION
It should be obvious that deadlocks are undesirable. In a
deadlock, processes never finish executing and the system
resources are tied up, preventing other job from ever starting.
NECESSARY CONDITIONS: -
1) MUTUAL EXCLUSION
3) NO PREEMPTION
4) CIRCULAR WAIT
RESOURCE – ALLOCATION GRAPH
Deadlocks can be described more precisely in terms of a directed
graph called a system resource-allocation graph.
R1 R3
P1 P2 P3
R2 R4
The set P, R, E :
P={P1, P2, P3}
R={R1,R2,R3,R4}
E={P1->R1,P2->R3,R1->P2,R2->P2,R2->P1,R3->P3}
Continue………..
To illustrate this concept, let us return to the resource-allocation
graph, which is given earlier.
R1 R3
P1 P2 P3
R2
R4
P1->R1->P2->R3->P3->R2->P1
P2->R3->P3->R2->P2
Process P1, P2 and P3 are deadlocked. Process P2 is waiting for
the resource R3, which is held by the process P3. Process on the
other hand, is waiting for either process P1 or process P2 to
release R1.
Continue………..
P2
R1
P1 P3
R2
P4
1. MUTUAL EXCLUSION
3. NO PREEMPTION
4. CIRCULAR WAIT
DEADLOCK AVOIDANCE
1. SAFE STATE
UNSAFE
DEADLOCK
SAFE
STEP 5 : Suppose that process Pi request resource Rj. The request can be granted
only if converting the request edge Pi to Rj is an assignment edge Rj -> Pi does
not result in the formation of a cycle in resource-allocation graph.
R1
P1 P2
R2
Continue………..
BANKER’S ALGORITHM
The deadlock avoidance algorithm that we describe next is applicable
to such a system, but is less efficient then the resource allocation graph
scheme. This algorithm is commonly known as Banker’s Algorithm. The
name was chosen because this algorithm could be used in a banking
system to ensure that the bank never allocates its available case such that
it can no longer satisfy the need of its customers.
1. PROCESS TERMINATION
a) Abort all deadlocked Process
b) Abort One Process at a Time until the deadlock cycle
is eliminated
2. RESOURCE PREEMPTION
a) Select a Victim
b) Roll Back
c) Starvation