SlideShare a Scribd company logo
1 of 17
Download to read offline
Lecture 5

                           Deadlocks
                 5.1. Resource
                 5.2. Introduction to deadlocks
                 5.3. The ostrich algorithm
                 5.4. Deadlock detection and recovery




Sistem Operasi              http://fasilkom.narotama.ac.id/
                                                              1
Resources

• Examples of computer resources
   – printers
   – tape drives
   – tables
• Processes need access to resources in reasonable order
• Suppose a process holds resource A and requests
  resource B
   – at same time another process holds B and requests A
   – both are blocked and remain so

   Sistem Operasi       http://fasilkom.narotama.ac.id/
                                                           2
Resources (1)

• Deadlocks occur when …
  – processes are granted exclusive access to devices
  – we refer to these devices generally as resources
• Preemptable resources
  – can be taken away from a process with no ill effects
• Nonpreemptable resources
  – will cause the process to fail if taken away

  Sistem Operasi     http://fasilkom.narotama.ac.id/
                                                           3
Resources (2)

•      Sequence of events required to use a resource
     1. request the resource
     2. use the resource
     3. release the resource


•        Must wait if request is denied
     –      requesting process may be blocked
     –      may fail with error code
    Sistem Operasi       http://fasilkom.narotama.ac.id/
                                                           4
Introduction to Deadlocks

• Formal definition :
  A set of processes is deadlocked if each process in the set is waiting
  for an event that only another process in the set can cause
• Usually the event is release of a currently held resource
• None of the processes can …
   – run
   – release resources
   – be awakened


    Sistem Operasi        http://fasilkom.narotama.ac.id/
                                                                           5
Four Conditions for Deadlock

1.        Mutual exclusion condition
      •     each resource assigned to 1 process or is available
2.        Hold and wait condition
      •     process holding resources can request additional
3.        No preemption condition
      •     previously granted resources cannot forcibly taken away
4.        Circular wait condition
      •     must be a circular chain of 2 or more processes
      •     each is waiting for resource held by next member of the
            chain
     Sistem Operasi          http://fasilkom.narotama.ac.id/
                                                                      6
Deadlock Modeling (2)
• Modeled with directed graphs




     – resource R assigned to process A
     – process B is requesting/waiting for resource S
     – process C and D are in deadlock over resources T and U
Sistem Operasi        http://fasilkom.narotama.ac.id/
                                                                7
Deadlock Modeling (3)

Strategies for dealing with Deadlocks
     1.        just ignore the problem altogether
     2.        detection and recovery
     3.        dynamic avoidance
           •      careful resource allocation
     4.        prevention
           •      negating one of the four necessary conditions



Sistem Operasi               http://fasilkom.narotama.ac.id/
                                                                  8
Deadlock Modeling (4)
                         A               B              C




Sistem Operasi        http://fasilkom.narotama.ac.id/
                    How deadlock occurs                     9
Deadlock Modeling (5)




                        (o)                (p)            (q)

Sistem Operasi          http://fasilkom.narotama.ac.id/
                  How deadlock can be avoided                   10
The Ostrich Algorithm
• Pretend there is no problem
• Reasonable if
     – deadlocks occur very rarely
     – cost of prevention is high
• UNIX and Windows takes this approach
• It is a trade off between
     – convenience
     – correctness

Sistem Operasi         http://fasilkom.narotama.ac.id/
                                                         11
Detection with One Resource of Each Type (1)




• Note the resource ownership and requests
• A cycle can be found within the graph, denoting deadlock

  Sistem Operasi    http://fasilkom.narotama.ac.id/
                                                        12
Detection with One Resource of Each Type (2)




 Data structures needed by deadlock detection algorithm

  Sistem Operasi    http://fasilkom.narotama.ac.id/
                                                          13
Detection with One Resource of Each Type (3)




 An example for the deadlock detection algorithm
  Sistem Operasi   http://fasilkom.narotama.ac.id/
                                                     14
Recovery from Deadlock (1)

• Recovery through preemption
     – take a resource from some other process
     – depends on nature of the resource
• Recovery through rollback
     – checkpoint a process periodically
     – use this saved state
     – restart the process if it is found deadlocked


Sistem Operasi       http://fasilkom.narotama.ac.id/
                                                       15
Recovery from Deadlock (2)


• Recovery through killing processes
   –   crudest but simplest way to break a deadlock
   –   kill one of the processes in the deadlock cycle
   –   the other processes get its resources
   –   choose process that can be rerun from the beginning




 Sistem Operasi       http://fasilkom.narotama.ac.id/
                                                             16
Question/Discussion




Sistem Operasi        http://fasilkom.narotama.ac.id/
                                                        17

More Related Content

Viewers also liked

Patrick Lightbody Presentation Tae Slides
Patrick Lightbody Presentation Tae SlidesPatrick Lightbody Presentation Tae Slides
Patrick Lightbody Presentation Tae Slides
Ajax Experience 2009
 
Tom Ferry Presentation
Tom Ferry PresentationTom Ferry Presentation
Tom Ferry Presentation
Jim Marks
 
Upgrading Share Point Portal Server 2003 Customizations To Share Point Server...
Upgrading Share Point Portal Server 2003 Customizations To Share Point Server...Upgrading Share Point Portal Server 2003 Customizations To Share Point Server...
Upgrading Share Point Portal Server 2003 Customizations To Share Point Server...
RCSLLC
 
Colin Clark Accessible U Is With J Query And Infusion[1]
Colin Clark Accessible U Is With J Query And Infusion[1]Colin Clark Accessible U Is With J Query And Infusion[1]
Colin Clark Accessible U Is With J Query And Infusion[1]
Ajax Experience 2009
 
201104.wv.uva college peacebuilding le co
201104.wv.uva college peacebuilding le co201104.wv.uva college peacebuilding le co
201104.wv.uva college peacebuilding le co
Wout Visser
 
موسوعة غينس للارقام القياسيه 3
موسوعة غينس للارقام القياسيه 3موسوعة غينس للارقام القياسيه 3
موسوعة غينس للارقام القياسيه 3
arabogrop
 
Ted Husted Presentation Testing The Testers Ae2009
Ted Husted Presentation Testing The Testers Ae2009Ted Husted Presentation Testing The Testers Ae2009
Ted Husted Presentation Testing The Testers Ae2009
Ajax Experience 2009
 
Absolute Dating
Absolute DatingAbsolute Dating
Absolute Dating
charsh
 

Viewers also liked (20)

Patrick Lightbody Presentation Tae Slides
Patrick Lightbody Presentation Tae SlidesPatrick Lightbody Presentation Tae Slides
Patrick Lightbody Presentation Tae Slides
 
Tom Ferry Presentation
Tom Ferry PresentationTom Ferry Presentation
Tom Ferry Presentation
 
Upgrading Share Point Portal Server 2003 Customizations To Share Point Server...
Upgrading Share Point Portal Server 2003 Customizations To Share Point Server...Upgrading Share Point Portal Server 2003 Customizations To Share Point Server...
Upgrading Share Point Portal Server 2003 Customizations To Share Point Server...
 
Cardiovascular system or the circulatory system
Cardiovascular system or the circulatory systemCardiovascular system or the circulatory system
Cardiovascular system or the circulatory system
 
Facebook, Brands and TV Preview Next Conference 2010 Berlin
Facebook, Brands and TV  Preview Next Conference 2010 BerlinFacebook, Brands and TV  Preview Next Conference 2010 Berlin
Facebook, Brands and TV Preview Next Conference 2010 Berlin
 
Redes Sociales2
Redes Sociales2Redes Sociales2
Redes Sociales2
 
Kurikulum 2013 SMA
Kurikulum 2013 SMAKurikulum 2013 SMA
Kurikulum 2013 SMA
 
Sheepshead bay
Sheepshead baySheepshead bay
Sheepshead bay
 
Aplicaciones moviles
Aplicaciones movilesAplicaciones moviles
Aplicaciones moviles
 
Colin Clark Accessible U Is With J Query And Infusion[1]
Colin Clark Accessible U Is With J Query And Infusion[1]Colin Clark Accessible U Is With J Query And Infusion[1]
Colin Clark Accessible U Is With J Query And Infusion[1]
 
201104.wv.uva college peacebuilding le co
201104.wv.uva college peacebuilding le co201104.wv.uva college peacebuilding le co
201104.wv.uva college peacebuilding le co
 
S4 tarea4 gania
S4 tarea4 ganiaS4 tarea4 gania
S4 tarea4 gania
 
Samiya Hethcock's Javita Weight Loss Testimonial
Samiya Hethcock's Javita Weight Loss TestimonialSamiya Hethcock's Javita Weight Loss Testimonial
Samiya Hethcock's Javita Weight Loss Testimonial
 
موسوعة غينس للارقام القياسيه 3
موسوعة غينس للارقام القياسيه 3موسوعة غينس للارقام القياسيه 3
موسوعة غينس للارقام القياسيه 3
 
信息分类和方法
信息分类和方法信息分类和方法
信息分类和方法
 
Test Analyst 3 + Yrs Manual Automation Theme
Test Analyst 3 + Yrs Manual Automation ThemeTest Analyst 3 + Yrs Manual Automation Theme
Test Analyst 3 + Yrs Manual Automation Theme
 
Ted Husted Presentation Testing The Testers Ae2009
Ted Husted Presentation Testing The Testers Ae2009Ted Husted Presentation Testing The Testers Ae2009
Ted Husted Presentation Testing The Testers Ae2009
 
Absolute Dating
Absolute DatingAbsolute Dating
Absolute Dating
 
Wave Energy
Wave EnergyWave Energy
Wave Energy
 
Variability
VariabilityVariability
Variability
 

Similar to Kcd226 Sistem Operasi Lecture05

Kcd226 Sistem Operasi Lecture04
Kcd226 Sistem Operasi Lecture04Kcd226 Sistem Operasi Lecture04
Kcd226 Sistem Operasi Lecture04
Cahyo Darujati
 
28 to 29 detection
28 to 29 detection 28 to 29 detection
28 to 29 detection
myrajendra
 
Lecture 6- Deadlocks (1) (1).pptx
Lecture 6- Deadlocks (1) (1).pptxLecture 6- Deadlocks (1) (1).pptx
Lecture 6- Deadlocks (1) (1).pptx
Amanuelmergia
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
Google
 

Similar to Kcd226 Sistem Operasi Lecture05 (20)

3 (2).ppt
3 (2).ppt3 (2).ppt
3 (2).ppt
 
3 (1) [Autosaved].ppt
3 (1) [Autosaved].ppt3 (1) [Autosaved].ppt
3 (1) [Autosaved].ppt
 
deadlock and starvation resources allocation.pptx
deadlock and starvation resources allocation.pptxdeadlock and starvation resources allocation.pptx
deadlock and starvation resources allocation.pptx
 
Kcd226 Sistem Operasi Lecture04
Kcd226 Sistem Operasi Lecture04Kcd226 Sistem Operasi Lecture04
Kcd226 Sistem Operasi Lecture04
 
06-Deadlocks.ppt
06-Deadlocks.ppt06-Deadlocks.ppt
06-Deadlocks.ppt
 
chapter06-new.pptx
chapter06-new.pptxchapter06-new.pptx
chapter06-new.pptx
 
OS-Part-06.pdf
OS-Part-06.pdfOS-Part-06.pdf
OS-Part-06.pdf
 
28 to 29 detection
28 to 29 detection 28 to 29 detection
28 to 29 detection
 
Lecture 6- Deadlocks (1) (1).pptx
Lecture 6- Deadlocks (1) (1).pptxLecture 6- Deadlocks (1) (1).pptx
Lecture 6- Deadlocks (1) (1).pptx
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
 
Lecture 6- Deadlocks.pptx
Lecture 6- Deadlocks.pptxLecture 6- Deadlocks.pptx
Lecture 6- Deadlocks.pptx
 
Deadlocks2
Deadlocks2Deadlocks2
Deadlocks2
 
Deadlocks Part- I.pdf
Deadlocks Part- I.pdfDeadlocks Part- I.pdf
Deadlocks Part- I.pdf
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Unit 3 part 2(DEADLOCK)
Unit 3 part 2(DEADLOCK)Unit 3 part 2(DEADLOCK)
Unit 3 part 2(DEADLOCK)
 
Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Operating system - Deadlock
Operating system - DeadlockOperating system - Deadlock
Operating system - Deadlock
 
Chapter06.ppt
Chapter06.pptChapter06.ppt
Chapter06.ppt
 
3.6 Deadlock-operating system unit 3.pptx
3.6 Deadlock-operating system unit 3.pptx3.6 Deadlock-operating system unit 3.pptx
3.6 Deadlock-operating system unit 3.pptx
 

More from Cahyo Darujati

01.welcome.ppt.sosialisasi.skkni.surabaya
01.welcome.ppt.sosialisasi.skkni.surabaya01.welcome.ppt.sosialisasi.skkni.surabaya
01.welcome.ppt.sosialisasi.skkni.surabaya
Cahyo Darujati
 
Kbk436 Sistem Operasi Lanjut Lecture02
Kbk436 Sistem Operasi Lanjut Lecture02Kbk436 Sistem Operasi Lanjut Lecture02
Kbk436 Sistem Operasi Lanjut Lecture02
Cahyo Darujati
 
Kbk436 Sistem Operasi Lanjut Lecture01
Kbk436 Sistem Operasi Lanjut Lecture01Kbk436 Sistem Operasi Lanjut Lecture01
Kbk436 Sistem Operasi Lanjut Lecture01
Cahyo Darujati
 
Kcd226 Sistem Operasi Lecture01
Kcd226 Sistem Operasi Lecture01Kcd226 Sistem Operasi Lecture01
Kcd226 Sistem Operasi Lecture01
Cahyo Darujati
 
Kcd226 Sistem Operasi Lecture03
Kcd226 Sistem Operasi Lecture03Kcd226 Sistem Operasi Lecture03
Kcd226 Sistem Operasi Lecture03
Cahyo Darujati
 
Kcd226 Sistem Operasi Lecture02
Kcd226 Sistem Operasi Lecture02Kcd226 Sistem Operasi Lecture02
Kcd226 Sistem Operasi Lecture02
Cahyo Darujati
 

More from Cahyo Darujati (16)

Presentasi jaring pengaman sandi untuk mendukung spbe 29042019 rev2
Presentasi jaring pengaman sandi untuk mendukung spbe 29042019 rev2Presentasi jaring pengaman sandi untuk mendukung spbe 29042019 rev2
Presentasi jaring pengaman sandi untuk mendukung spbe 29042019 rev2
 
Melindungi, Mengamankan, Menanggulangi, dan Memulihkan Keamanan Informasi Pen...
Melindungi, Mengamankan, Menanggulangi, dan Memulihkan Keamanan Informasi Pen...Melindungi, Mengamankan, Menanggulangi, dan Memulihkan Keamanan Informasi Pen...
Melindungi, Mengamankan, Menanggulangi, dan Memulihkan Keamanan Informasi Pen...
 
Melawan penyebaran hoax di media sosial dengan teknologi
Melawan penyebaran hoax di media sosial dengan teknologiMelawan penyebaran hoax di media sosial dengan teknologi
Melawan penyebaran hoax di media sosial dengan teknologi
 
Security is a process not a magic
Security is a process not a magicSecurity is a process not a magic
Security is a process not a magic
 
01.welcome.ppt.sosialisasi.skkni.surabaya
01.welcome.ppt.sosialisasi.skkni.surabaya01.welcome.ppt.sosialisasi.skkni.surabaya
01.welcome.ppt.sosialisasi.skkni.surabaya
 
Mengatur referensi penelitian
Mengatur referensi penelitianMengatur referensi penelitian
Mengatur referensi penelitian
 
Tatakelola Teknologi Informasi
Tatakelola Teknologi InformasiTatakelola Teknologi Informasi
Tatakelola Teknologi Informasi
 
Pen test methodology
Pen test methodologyPen test methodology
Pen test methodology
 
pengenalan ipv6
pengenalan ipv6pengenalan ipv6
pengenalan ipv6
 
Kbk436 Sistem Operasi Lanjut Lecture02
Kbk436 Sistem Operasi Lanjut Lecture02Kbk436 Sistem Operasi Lanjut Lecture02
Kbk436 Sistem Operasi Lanjut Lecture02
 
Kbk436 Sistem Operasi Lanjut Lecture01
Kbk436 Sistem Operasi Lanjut Lecture01Kbk436 Sistem Operasi Lanjut Lecture01
Kbk436 Sistem Operasi Lanjut Lecture01
 
Kcd226 Sistem Operasi Lecture01
Kcd226 Sistem Operasi Lecture01Kcd226 Sistem Operasi Lecture01
Kcd226 Sistem Operasi Lecture01
 
Kcd226 Sistem Operasi Lecture03
Kcd226 Sistem Operasi Lecture03Kcd226 Sistem Operasi Lecture03
Kcd226 Sistem Operasi Lecture03
 
Kcd226 Sistem Operasi Lecture02
Kcd226 Sistem Operasi Lecture02Kcd226 Sistem Operasi Lecture02
Kcd226 Sistem Operasi Lecture02
 
Kbk436 Sistem Operasi Lanjut Lecture01
Kbk436 Sistem Operasi Lanjut Lecture01Kbk436 Sistem Operasi Lanjut Lecture01
Kbk436 Sistem Operasi Lanjut Lecture01
 
Kcd226 Sistem Operasi Lecture01
Kcd226 Sistem Operasi Lecture01Kcd226 Sistem Operasi Lecture01
Kcd226 Sistem Operasi Lecture01
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 

Kcd226 Sistem Operasi Lecture05

  • 1. Lecture 5 Deadlocks 5.1. Resource 5.2. Introduction to deadlocks 5.3. The ostrich algorithm 5.4. Deadlock detection and recovery Sistem Operasi http://fasilkom.narotama.ac.id/ 1
  • 2. Resources • Examples of computer resources – printers – tape drives – tables • Processes need access to resources in reasonable order • Suppose a process holds resource A and requests resource B – at same time another process holds B and requests A – both are blocked and remain so Sistem Operasi http://fasilkom.narotama.ac.id/ 2
  • 3. Resources (1) • Deadlocks occur when … – processes are granted exclusive access to devices – we refer to these devices generally as resources • Preemptable resources – can be taken away from a process with no ill effects • Nonpreemptable resources – will cause the process to fail if taken away Sistem Operasi http://fasilkom.narotama.ac.id/ 3
  • 4. Resources (2) • Sequence of events required to use a resource 1. request the resource 2. use the resource 3. release the resource • Must wait if request is denied – requesting process may be blocked – may fail with error code Sistem Operasi http://fasilkom.narotama.ac.id/ 4
  • 5. Introduction to Deadlocks • Formal definition : A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause • Usually the event is release of a currently held resource • None of the processes can … – run – release resources – be awakened Sistem Operasi http://fasilkom.narotama.ac.id/ 5
  • 6. Four Conditions for Deadlock 1. Mutual exclusion condition • each resource assigned to 1 process or is available 2. Hold and wait condition • process holding resources can request additional 3. No preemption condition • previously granted resources cannot forcibly taken away 4. Circular wait condition • must be a circular chain of 2 or more processes • each is waiting for resource held by next member of the chain Sistem Operasi http://fasilkom.narotama.ac.id/ 6
  • 7. Deadlock Modeling (2) • Modeled with directed graphs – resource R assigned to process A – process B is requesting/waiting for resource S – process C and D are in deadlock over resources T and U Sistem Operasi http://fasilkom.narotama.ac.id/ 7
  • 8. Deadlock Modeling (3) Strategies for dealing with Deadlocks 1. just ignore the problem altogether 2. detection and recovery 3. dynamic avoidance • careful resource allocation 4. prevention • negating one of the four necessary conditions Sistem Operasi http://fasilkom.narotama.ac.id/ 8
  • 9. Deadlock Modeling (4) A B C Sistem Operasi http://fasilkom.narotama.ac.id/ How deadlock occurs 9
  • 10. Deadlock Modeling (5) (o) (p) (q) Sistem Operasi http://fasilkom.narotama.ac.id/ How deadlock can be avoided 10
  • 11. The Ostrich Algorithm • Pretend there is no problem • Reasonable if – deadlocks occur very rarely – cost of prevention is high • UNIX and Windows takes this approach • It is a trade off between – convenience – correctness Sistem Operasi http://fasilkom.narotama.ac.id/ 11
  • 12. Detection with One Resource of Each Type (1) • Note the resource ownership and requests • A cycle can be found within the graph, denoting deadlock Sistem Operasi http://fasilkom.narotama.ac.id/ 12
  • 13. Detection with One Resource of Each Type (2) Data structures needed by deadlock detection algorithm Sistem Operasi http://fasilkom.narotama.ac.id/ 13
  • 14. Detection with One Resource of Each Type (3) An example for the deadlock detection algorithm Sistem Operasi http://fasilkom.narotama.ac.id/ 14
  • 15. Recovery from Deadlock (1) • Recovery through preemption – take a resource from some other process – depends on nature of the resource • Recovery through rollback – checkpoint a process periodically – use this saved state – restart the process if it is found deadlocked Sistem Operasi http://fasilkom.narotama.ac.id/ 15
  • 16. Recovery from Deadlock (2) • Recovery through killing processes – crudest but simplest way to break a deadlock – kill one of the processes in the deadlock cycle – the other processes get its resources – choose process that can be rerun from the beginning Sistem Operasi http://fasilkom.narotama.ac.id/ 16
  • 17. Question/Discussion Sistem Operasi http://fasilkom.narotama.ac.id/ 17