SlideShare una empresa de Scribd logo
1 de 27
Understand Process Management
• Deadlocks




                                     1
•HOME     PREVIOUS TOPIC
NEXT
•PREVIOUS QUESTION PAPERS
FOR OS
•CPP TUTORIALS




                            2
Recap

In the last class, you have learnt
• Semaphore
• IPC
Objectives
 On completion of this class, you would be able to
 know:

• Definition Dead Lock

• Necessary conditions for the occurrence of Dead lock

• Resource Allocation Graph

• Resource Allocation Graph with a Deadlock


                                                     4
Deadlocks
•In a multiprogramming environment, several processes
may compete for a finite number of resources
•A process requests resources, if the resources are not
available at that time, the process enters a wait state
• Some times a waiting process may never again able to
change state, because the resources they have requested
are held by other waiting processes
•This situation is called “Deadlock”
                                                          5
Deadlock

• A set of process is in a deadlock state,
   – when every process in the set is waiting far an event,

   – that can be caused only by another process in the set

• The resources can be either Physical resources
   – like prints, tape drives, memory space, and CPU cycles

    or Logical resources
   – like files, semaphores and monitors


                                                              6
Deadlock


Example:
• Consider a system with one printer and one DVD drive
• Suppose that process Pi is holding the DVD and process

  Pj is holding the printer

• If Pi requests the printer and Pj requests the DVD
  drive, a deadlock occurs


                                                       7
Necessary Conditions for Deadlock

1. Mutual exclusion

2. Hold and wait

3. No Preemption

4. Circular wait


                                       8
Necessary Conditions for Deadlock

Mutual exclusion

•At least one resource must be held in a non-sharable

 mode

•The requesting process must be delayed until the

 resource has been released

                                                        9
Necessary Conditions for Deadlock

Hold and wait
•A process must exist that is holding at least one resource
•The process is waiting to acquire additional resources
 which are currently being held by other processes




                                                       10
Necessary Conditions for Deadlock


No preemption
• Resources cannot be preempted

• A resource can be released only voluntarily by the
  process holding it




                                                   11
Necessary Conditions for Deadlock
Circular wait
• A set{P0,P1,…. ,Pn} of waiting processes must exist
  such that
• P0 is waiting for resource held by P1


• P1 is waiting for resource held by P2


• Pn-1 is waiting for resource held by Pn


• Pn is waiting for resource held by P0
                                                        12
Resource Allocation Graph
• Deadlocks can be described more precisely in terms of a
  directed graph called a system resource – allocation graph
• This graph consists of a set of vertices V and set of edges E
• The set of vertices V is partitioned into two different types of
  nodes:
   P = { P1,P2,----, Pn} – the set consisting of all the
                       active process in the system
   R = { R1,R2,----,Rm} - the set consisting of all
                        resource types in the system          13
Resource Allocation Graph

• Pi Rj – Signifies that process Pi has requested an

  instance of resource type Rj and is currently waiting for
  that resource – request edge

• Rj Pi - signifies that an instance of resource type Rj has

  been allocated to process Pi – assignment edge

• Each process Pi is represented by a circle

• Each resource type Rj is represented by a rectangle
                                                         14
Resource Allocation Graph
The resource allocation graph depicts the following
  situation
The sets 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}




                                                              15
Resource Instances

• One instance of resource type R1


• Two instances of resource type R2


• One instance of resource type R3


• Three instances of resource type R4

                                        16
Process States

• Process P1 is holding an instance of resource R2
  and is waiting for R1


• Process P2 is holding an instance of R1 and R2 and is
  waiting for R3


• Process P3 is holding an instance of R3


                                                     17
Resource Allocation Graph
      R1             R3




P1              P2        P3




       R2
            Fig 1
                     R4
                                 18
Resource Allocation Graph
Resource Allocation

• Suppose P3 requests R2

• At this point two minimal cycles exist in the system :

• P1    R1 P2     R3 P3 R2   P1

• P2    R3   P3    R2   P2

• Process P1, P2 and P3 are Deadlocked



                                                      20
Resource – Allocation Graph with a Deadlock
            R1            R3




       P1            P2        P3




             R2   Fig 2
                          R4
                                          21
Resource – Allocation

• There is a cycle P1   R1 P3 P1

• But there is no deadlock

• If a resource-allocation graph does not
  have a cycle, then the system is not in
  a deadlocked state
• If there is a cycle, then the system may
                                             Fig 2
  or may not be in a deadlocked state
                                                     22
Summary
 In this class, you have learnt :
• Deadlock
• The necessary conditions for a deadlock to occur namely
• Mutual exclusion
• Hold and wait
• No preemption
• Circular wait
• Resource allocation graphs
                                                    23
Frequently Asked Questions

1. Explain the necessary conditions that should
   exist in a system for a deadlock to occur

2. Explain about resource-allocation graphs




                                                  24
Quiz
1. Characteristics of deadlock
   a) No Hold and wait
   b) Circular wait
   c) Preemption
   d) All of the above

2. Deadlock occurrence
   a)In sharable mode
   b)In non-sharable mode

                                 25
Other subject materials
•   Web designing
•   Micro processors
•   C++ tutorials
•   java

home
Quiz

3. A directed edge Pi--Rj is called a -------

    a) Request edge

4. Deadlocks can be described in terms of -------

    a)Resource - allocation

5. A directed edge Rj --- Pi is called an---

    a) Assignment edge
                                                    27

Más contenido relacionado

La actualidad más candente

Errors (Concurrency)
Errors (Concurrency)Errors (Concurrency)
Errors (Concurrency)
Sri Prasanna
 
Drooling for drools (JBoss webex)
Drooling for drools (JBoss webex)Drooling for drools (JBoss webex)
Drooling for drools (JBoss webex)
Geoffrey De Smet
 

La actualidad más candente (20)

Lect05
Lect05Lect05
Lect05
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURYdeadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
deadlock detection using Goldman's algorithm by ANIKET CHOUDHURY
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlocks
 Deadlocks Deadlocks
Deadlocks
 
Errors (Concurrency)
Errors (Concurrency)Errors (Concurrency)
Errors (Concurrency)
 
Ch8
Ch8Ch8
Ch8
 
Deadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbianDeadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbian
 
Deadlock Presentation
Deadlock PresentationDeadlock Presentation
Deadlock Presentation
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
Chapter06
Chapter06Chapter06
Chapter06
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock Avoidance in Operating System
Deadlock Avoidance in Operating SystemDeadlock Avoidance in Operating System
Deadlock Avoidance in Operating System
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
 
Drooling for drools (JBoss webex)
Drooling for drools (JBoss webex)Drooling for drools (JBoss webex)
Drooling for drools (JBoss webex)
 
deadlock
deadlockdeadlock
deadlock
 
Operating system - Deadlock
Operating system - DeadlockOperating system - Deadlock
Operating system - Deadlock
 
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
 
10. deadlock
10. deadlock10. deadlock
10. deadlock
 
Deadlock- Operating System
Deadlock- Operating SystemDeadlock- Operating System
Deadlock- Operating System
 

Destacado

Operating System Deadlock Galvin
Operating System  Deadlock GalvinOperating System  Deadlock Galvin
Operating System Deadlock Galvin
Sonali Chauhan
 
12 process control blocks
12 process control blocks12 process control blocks
12 process control blocks
myrajendra
 
Operating system interview question
Operating system interview questionOperating system interview question
Operating system interview question
sriram saravanan
 
11 process definition
11 process definition11 process definition
11 process definition
myrajendra
 
31 address binding, dynamic loading
31 address binding, dynamic loading31 address binding, dynamic loading
31 address binding, dynamic loading
myrajendra
 
12 process control blocks
12 process control blocks12 process control blocks
12 process control blocks
myrajendra
 
Access control presentation
Access control presentationAccess control presentation
Access control presentation
Saqib Raza
 
Double level directory structure 55(1)
Double level directory structure 55(1)Double level directory structure 55(1)
Double level directory structure 55(1)
myrajendra
 
Mutual Exclusion Election (Distributed computing)
Mutual Exclusion Election (Distributed computing)Mutual Exclusion Election (Distributed computing)
Mutual Exclusion Election (Distributed computing)
Sri Prasanna
 

Destacado (20)

Deadlock
DeadlockDeadlock
Deadlock
 
Operating System Deadlock Galvin
Operating System  Deadlock GalvinOperating System  Deadlock Galvin
Operating System Deadlock Galvin
 
Mutual exclusion and sync
Mutual exclusion and syncMutual exclusion and sync
Mutual exclusion and sync
 
9 cm402.13
9 cm402.139 cm402.13
9 cm402.13
 
12 process control blocks
12 process control blocks12 process control blocks
12 process control blocks
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
Operating system interview question
Operating system interview questionOperating system interview question
Operating system interview question
 
11 process definition
11 process definition11 process definition
11 process definition
 
31 address binding, dynamic loading
31 address binding, dynamic loading31 address binding, dynamic loading
31 address binding, dynamic loading
 
12 process control blocks
12 process control blocks12 process control blocks
12 process control blocks
 
Dead Lock In Operating Systems
Dead Lock In Operating SystemsDead Lock In Operating Systems
Dead Lock In Operating Systems
 
Access control presentation
Access control presentationAccess control presentation
Access control presentation
 
Double level directory structure 55(1)
Double level directory structure 55(1)Double level directory structure 55(1)
Double level directory structure 55(1)
 
Deadlock
DeadlockDeadlock
Deadlock
 
Mutual Exclusion Election (Distributed computing)
Mutual Exclusion Election (Distributed computing)Mutual Exclusion Election (Distributed computing)
Mutual Exclusion Election (Distributed computing)
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Access Control: Principles and Practice
Access Control: Principles and PracticeAccess Control: Principles and Practice
Access Control: Principles and Practice
 
System protection in Operating System
System protection in Operating SystemSystem protection in Operating System
System protection in Operating System
 
Chapter 7 - Deadlocks
Chapter 7 - DeadlocksChapter 7 - Deadlocks
Chapter 7 - Deadlocks
 
Types of operating system
Types of operating systemTypes of operating system
Types of operating system
 

Similar a 23 deadlock

OS Module-3 (2).pptx
OS Module-3 (2).pptxOS Module-3 (2).pptx
OS Module-3 (2).pptx
KokilaK25
 
26 to 27deadlockavoidance
26 to 27deadlockavoidance26 to 27deadlockavoidance
26 to 27deadlockavoidance
myrajendra
 
DeadlockMar21.ppt
DeadlockMar21.pptDeadlockMar21.ppt
DeadlockMar21.ppt
hetrathod001
 
Deadlock in Real Time operating Systempptx
Deadlock in Real Time operating SystempptxDeadlock in Real Time operating Systempptx
Deadlock in Real Time operating Systempptx
ssuserca5764
 
Module 3 Deadlocks.pptx
Module 3 Deadlocks.pptxModule 3 Deadlocks.pptx
Module 3 Deadlocks.pptx
shreesha16
 

Similar a 23 deadlock (20)

Chapter5_Deadlock.pptx
Chapter5_Deadlock.pptxChapter5_Deadlock.pptx
Chapter5_Deadlock.pptx
 
6. Deadlock_1640227623705.pptx
6. Deadlock_1640227623705.pptx6. Deadlock_1640227623705.pptx
6. Deadlock_1640227623705.pptx
 
Os5
Os5Os5
Os5
 
Deadlocks Part- I.pdf
Deadlocks Part- I.pdfDeadlocks Part- I.pdf
Deadlocks Part- I.pdf
 
OS Module-3 (2).pptx
OS Module-3 (2).pptxOS Module-3 (2).pptx
OS Module-3 (2).pptx
 
Ch07 deadlocks
Ch07 deadlocksCh07 deadlocks
Ch07 deadlocks
 
26 to 27deadlockavoidance
26 to 27deadlockavoidance26 to 27deadlockavoidance
26 to 27deadlockavoidance
 
OS deadlock.pptx
OS deadlock.pptxOS deadlock.pptx
OS deadlock.pptx
 
deadlock part5 unit 2.ppt
deadlock part5 unit 2.pptdeadlock part5 unit 2.ppt
deadlock part5 unit 2.ppt
 
DeadlockMar21.ppt
DeadlockMar21.pptDeadlockMar21.ppt
DeadlockMar21.ppt
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock
DeadlockDeadlock
Deadlock
 
Ch7 deadlocks
Ch7   deadlocksCh7   deadlocks
Ch7 deadlocks
 
3 (1) [Autosaved].ppt
3 (1) [Autosaved].ppt3 (1) [Autosaved].ppt
3 (1) [Autosaved].ppt
 
Deadlock (1).ppt
Deadlock (1).pptDeadlock (1).ppt
Deadlock (1).ppt
 
Deadlock in Real Time operating Systempptx
Deadlock in Real Time operating SystempptxDeadlock in Real Time operating Systempptx
Deadlock in Real Time operating Systempptx
 
deadlocks.pptx
deadlocks.pptxdeadlocks.pptx
deadlocks.pptx
 
Module 3 Deadlocks.pptx
Module 3 Deadlocks.pptxModule 3 Deadlocks.pptx
Module 3 Deadlocks.pptx
 
Deadlock.pptx
Deadlock.pptxDeadlock.pptx
Deadlock.pptx
 

Más de myrajendra (20)

Fundamentals
FundamentalsFundamentals
Fundamentals
 
Data type
Data typeData type
Data type
 
Hibernate example1
Hibernate example1Hibernate example1
Hibernate example1
 
Jdbc workflow
Jdbc workflowJdbc workflow
Jdbc workflow
 
2 jdbc drivers
2 jdbc drivers2 jdbc drivers
2 jdbc drivers
 
3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
 
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
 
Dao example
Dao exampleDao example
Dao example
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
 
Internal
InternalInternal
Internal
 
3. elements
3. elements3. elements
3. elements
 
2. attributes
2. attributes2. attributes
2. attributes
 
1 introduction to html
1 introduction to html1 introduction to html
1 introduction to html
 
Headings
HeadingsHeadings
Headings
 
Forms
FormsForms
Forms
 
Css
CssCss
Css
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Starting jdbc
Starting jdbcStarting jdbc
Starting jdbc
 

23 deadlock

  • 2. •HOME PREVIOUS TOPIC NEXT •PREVIOUS QUESTION PAPERS FOR OS •CPP TUTORIALS 2
  • 3. Recap In the last class, you have learnt • Semaphore • IPC
  • 4. Objectives On completion of this class, you would be able to know: • Definition Dead Lock • Necessary conditions for the occurrence of Dead lock • Resource Allocation Graph • Resource Allocation Graph with a Deadlock 4
  • 5. Deadlocks •In a multiprogramming environment, several processes may compete for a finite number of resources •A process requests resources, if the resources are not available at that time, the process enters a wait state • Some times a waiting process may never again able to change state, because the resources they have requested are held by other waiting processes •This situation is called “Deadlock” 5
  • 6. Deadlock • A set of process is in a deadlock state, – when every process in the set is waiting far an event, – that can be caused only by another process in the set • The resources can be either Physical resources – like prints, tape drives, memory space, and CPU cycles or Logical resources – like files, semaphores and monitors 6
  • 7. Deadlock Example: • Consider a system with one printer and one DVD drive • Suppose that process Pi is holding the DVD and process Pj is holding the printer • If Pi requests the printer and Pj requests the DVD drive, a deadlock occurs 7
  • 8. Necessary Conditions for Deadlock 1. Mutual exclusion 2. Hold and wait 3. No Preemption 4. Circular wait 8
  • 9. Necessary Conditions for Deadlock Mutual exclusion •At least one resource must be held in a non-sharable mode •The requesting process must be delayed until the resource has been released 9
  • 10. Necessary Conditions for Deadlock Hold and wait •A process must exist that is holding at least one resource •The process is waiting to acquire additional resources which are currently being held by other processes 10
  • 11. Necessary Conditions for Deadlock No preemption • Resources cannot be preempted • A resource can be released only voluntarily by the process holding it 11
  • 12. Necessary Conditions for Deadlock Circular wait • A set{P0,P1,…. ,Pn} of waiting processes must exist such that • P0 is waiting for resource held by P1 • P1 is waiting for resource held by P2 • Pn-1 is waiting for resource held by Pn • Pn is waiting for resource held by P0 12
  • 13. Resource Allocation Graph • Deadlocks can be described more precisely in terms of a directed graph called a system resource – allocation graph • This graph consists of a set of vertices V and set of edges E • The set of vertices V is partitioned into two different types of nodes: P = { P1,P2,----, Pn} – the set consisting of all the active process in the system R = { R1,R2,----,Rm} - the set consisting of all resource types in the system 13
  • 14. Resource Allocation Graph • Pi Rj – Signifies that process Pi has requested an instance of resource type Rj and is currently waiting for that resource – request edge • Rj Pi - signifies that an instance of resource type Rj has been allocated to process Pi – assignment edge • Each process Pi is represented by a circle • Each resource type Rj is represented by a rectangle 14
  • 15. Resource Allocation Graph The resource allocation graph depicts the following situation The sets 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} 15
  • 16. Resource Instances • One instance of resource type R1 • Two instances of resource type R2 • One instance of resource type R3 • Three instances of resource type R4 16
  • 17. Process States • Process P1 is holding an instance of resource R2 and is waiting for R1 • Process P2 is holding an instance of R1 and R2 and is waiting for R3 • Process P3 is holding an instance of R3 17
  • 18. Resource Allocation Graph R1 R3 P1 P2 P3 R2 Fig 1 R4 18
  • 20. Resource Allocation • Suppose P3 requests R2 • At this point two minimal cycles exist in the system : • P1 R1 P2 R3 P3 R2 P1 • P2 R3 P3 R2 P2 • Process P1, P2 and P3 are Deadlocked 20
  • 21. Resource – Allocation Graph with a Deadlock R1 R3 P1 P2 P3 R2 Fig 2 R4 21
  • 22. Resource – Allocation • There is a cycle P1 R1 P3 P1 • But there is no deadlock • If a resource-allocation graph does not have a cycle, then the system is not in a deadlocked state • If there is a cycle, then the system may Fig 2 or may not be in a deadlocked state 22
  • 23. Summary In this class, you have learnt : • Deadlock • The necessary conditions for a deadlock to occur namely • Mutual exclusion • Hold and wait • No preemption • Circular wait • Resource allocation graphs 23
  • 24. Frequently Asked Questions 1. Explain the necessary conditions that should exist in a system for a deadlock to occur 2. Explain about resource-allocation graphs 24
  • 25. Quiz 1. Characteristics of deadlock a) No Hold and wait b) Circular wait c) Preemption d) All of the above 2. Deadlock occurrence a)In sharable mode b)In non-sharable mode 25
  • 26. Other subject materials • Web designing • Micro processors • C++ tutorials • java home
  • 27. Quiz 3. A directed edge Pi--Rj is called a ------- a) Request edge 4. Deadlocks can be described in terms of ------- a)Resource - allocation 5. A directed edge Rj --- Pi is called an--- a) Assignment edge 27