Академический Документы
Профессиональный Документы
Культура Документы
LECTURE - 8
K.ARIVUSELVAN
Assistant Professor (SG) (SITE)
VIT University
DEADLOCKS
The Deadlock Problem
Example1
(4) Circular wait: there exists a set {P0, P1, , Pn} of waiting processes
such that:
Deadlock Prevention
Deadlock Avoidance
Deadlock Prevention
Deadlock Avoidance
NOTE:
=> Sharable resource mutual exclusion not required ( Read only file
access by several process simultaneously). No dead lock
1st Protocol :
Example:
Copying data from Tape drive to Disk file, Sort Disk file, Print
Drawback:
Hold printer entire execution even printer need at last
Deadlock Prevention
2nd Protocol :
Example:
Request Tape drive & Disk
Release
Request Disk & Printer
Deadlock Prevention
(3) No Preemption:
Protocol :
Protocol :
Example:
Tape Drive = 1, Disk = 4, Printer = 10
Constraint :
=> Process that want to use both Tape & Printer at the same time
must first request Tape & then Printer
Deadlock Avoidance
Safe State:
Constraint:
Need
ABC
P0 743
P1 122
P2 600
P3 011
P4 431
Resource-Request Algorithm for Process Pi
ACTION TAKEN:
How?
Check if
this new
state is
Safe.
i.e.if a safe
Available = Available Requesti ;
sequence
exists
Allocationi = Allocationi + Requesti ;
4. If Finish [i] == true for all i, then the system is in a safe state.
Example (Cont.)
P0 10 4 7 7 4 3 304 753 10 5 7
Resource-allocation Graph
A visual ( mathematical ) way to determine if a deadlock has,
or may occur.
=> P = {P1, P2, , Pn}, the set consisting of all the processes in
the system.
Pi Pj if Pi is waiting for Pj
Data Structures:
Sequence <P0, P2, P3, P1, P4> will result in Finish[i] = true for all i.
Example (Cont.)
Request
ABC
P0 000
P1 202
P2 001
P3 100
P4 002
State of system?