Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Deadlock ppt
1. ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY,
BHOPAL
Department of Information Technology
SELF STUDY
Presentation
On
Deadlock
Presented By:-
DEEPAK YADAV
0105IT131027
Semester V09/03/15 1
Oriental Institute Of Science & Technology, Bhopal
2. The Deadlock Problem
EXAMPLES:
"It takes money to make money".
You can't get a job without experience; you can't get
experience without a job.
BACKGROUND:
The cause of deadlocks: Each process needing what another
process has. This results from sharing resources such as
memory devices, links.
Under normal operation, a resource allocations proceed like
this:
Request a resource (suspend until available if necessary.
Use the resource.
Release the resource.
09/03/15
2Oriental Institute Of Science & Technology,
Bhopal
3. Deadlock Characterization
Deadlock can arise if four conditions hold simultaneously.
Mutual exclusion: only one process at a time can use a
resource
Hold and wait: a process holding at least one resource is
waiting to acquire additional resources held by other processes
No preemption: a resource can be released only voluntarily by
the process holding it, after that process has completed its task
Circular wait: there exists a set {P0, P1, …, Pn} of waiting
processes such that P0 is waiting for a resource that is held by
P1, P1 is waiting for a resource that is held by P2, …, Pn–1 is
waiting for a resource that is held by Pn, and Pn is waiting for a
resource that is held by P0.09/03/15 3Oriental Institute Of Science & Technology,
Bhopal
4. Methods for Handling Deadlocks
Ensure that the system will never enter a
deadlock state – deadlock prevention
Allow the system to enter a deadlock state
and then recover
Ignore the problem and pretend that
deadlocks never occur in the system; used
by most operating systems, including UNIX
09/03/15 4Oriental Institute Of Science & Technology,
Bhopal
5. Do not allow one of the four conditions to occur.
Mutual exclusion:
a) Automatically holds for printers and other non-sharables.
b) Shared entities (read only files) don't need mutual exclusion
(and aren’t susceptible to deadlock.)
c) Prevention not possible, since some devices are intrinsically
non-sharable.
Hold and wait:
a) Collect all resources before execution.
b) A particular resource can only be requested when no others
are being held. A sequence of resources is always collected
beginning with the same one.
c) Utilization is low, starvation possible.
Deadlock Prevention
09/03/15 5Oriental Institute Of Science & Technology,
Bhopal
6. Example (Cont.)
The content of the matrix Need is defined to be Max –
Allocation
Need
A B C
P0 7 4 3
P1 1 2 2
P2 6 0 0
P3 0 1 1
P4 4 3 1
The system is in a safe state since the sequence < P1,
P3, P4, P2, P0> satisfies safety criteria
09/03/15 6
Oriental Institute Of Science & Technology,
Bhopal
7. NOTE: All deadlocks are unsafe, but all unsafes are
NOT deadlocks.
SAFE
DEADLOCK
UNSAFE
Only with luck will
processes avoid
deadlock.
O.S. can avoid
deadlock.
Deadlock Avoidance
09/03/15 7Oriental Institute Of Science & Technology,
Bhopal
8.
Single instance of a resource type
Use a resource-allocation graph
Multiple instances of a resource
type
Use the banker’s algorithm
Avoidance algorithms
09/03/15 8Oriental Institute Of Science & Technology,
Bhopal
9. Recovery from Deadlock:
Process Termination
Abort all deadlocked processes
Abort one process at a time until the deadlock cycle is
eliminated
In which order should we choose to abort?
Priority of the process
How long process has computed, and how much
longer to completion
Resources the process has used
Resources process needs to complete
How many processes will need to be terminated
Is process interactive or batch?
09/03/15 9Oriental Institute Of Science & Technology,
Bhopal
10. Recovery from Deadlock:
Resource Preemption
Selecting a victim – minimize cost
Rollback – return to some safe state,
restart process for that state
Problem: starvation – same process may
always be picked as victim, include number
of rollback in cost factor
09/03/15 10Oriental Institute Of Science & Technology,
Bhopal