Pundra University Of Science & Technology
Name: Shayek Parvez
CSE 3rd Batch, 7th semester
Roll No: C00315306010
Course Title: Operating System
Course Code: 313
Page: 1/7
Presentation Topic
Deadlock avoidance, Safe State,
Resource Allocation Graph
Page: 2/7
What is Deadlock avoidance
Deadlock is: A set of blocked processes each
holding a resource and waiting to acquire a
resource held by another process in the set.
Page: 3/7
The Conditions for Deadlock
1. Mutual Exclusion
• Only one process at a time may use a resource
2. Hold-and-Wait
• A process may hold allocated resources while awaiting
assignment of others
3. No Preemption
• A resource can be released only voluntarily by the
process holding it, after that process has completed its
Task
4. Circular Wait
• a closed chain of processes exists, such that each
process holds at least one resource needed by the next
process in the chain
Page: 4/7
Safe State
Q: Suppose there are four process in Execution with 12 instances of a Resources R
in a System. The Maximum need of each process & current allocation are given below.
Process Max Need Current Allocation
P1 8 3
P2 9 4
P3 5 2
P4 3 1
Ans: Total Resources = 12
Process Max Need Current
Allocation
Future
Allocation
P1 8 3 5
P2 9 4 5
P3 5 2 3
P4 3 1 2
10 resources allocated, 2 resources available
P4 = 1+2 = 3
P3 = 3+2 = 5
P2 = 4+5 = 9
P1 = 3+5 = 8
So the Answer Will be P4,P3,P1,P2 Page: 5/7
OS - Resource Allocation Graph
P1 P2 P3
R1 R2
R3 R4
Resource Allocation Graph
Process
Resources
Not Sharable
(only 1 process can be accessed)
instance
(sharable, can be allocated
2 processes at a time)
Allocation edge
(Directed Resource to Process)
Request edge
(Directed Process to Resource)
Page: 6/7
Thank You

Deadlock avoidance (Safe State, Resource Allocation Graph Algorithm)

  • 1.
    Pundra University OfScience & Technology Name: Shayek Parvez CSE 3rd Batch, 7th semester Roll No: C00315306010 Course Title: Operating System Course Code: 313 Page: 1/7
  • 2.
    Presentation Topic Deadlock avoidance,Safe State, Resource Allocation Graph Page: 2/7
  • 3.
    What is Deadlockavoidance Deadlock is: A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set. Page: 3/7
  • 4.
    The Conditions forDeadlock 1. Mutual Exclusion • Only one process at a time may use a resource 2. Hold-and-Wait • A process may hold allocated resources while awaiting assignment of others 3. No Preemption • A resource can be released only voluntarily by the process holding it, after that process has completed its Task 4. Circular Wait • a closed chain of processes exists, such that each process holds at least one resource needed by the next process in the chain Page: 4/7
  • 5.
    Safe State Q: Supposethere are four process in Execution with 12 instances of a Resources R in a System. The Maximum need of each process & current allocation are given below. Process Max Need Current Allocation P1 8 3 P2 9 4 P3 5 2 P4 3 1 Ans: Total Resources = 12 Process Max Need Current Allocation Future Allocation P1 8 3 5 P2 9 4 5 P3 5 2 3 P4 3 1 2 10 resources allocated, 2 resources available P4 = 1+2 = 3 P3 = 3+2 = 5 P2 = 4+5 = 9 P1 = 3+5 = 8 So the Answer Will be P4,P3,P1,P2 Page: 5/7
  • 6.
    OS - ResourceAllocation Graph P1 P2 P3 R1 R2 R3 R4 Resource Allocation Graph Process Resources Not Sharable (only 1 process can be accessed) instance (sharable, can be allocated 2 processes at a time) Allocation edge (Directed Resource to Process) Request edge (Directed Process to Resource) Page: 6/7
  • 7.