SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
Sistem Operasi
    IKH311

  Deadlock
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
                                                              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
Resources (2)

   Sequence of events required to use a resource
              request the resource
              use the resource
              release the resource
   Must wait if request is denied
              requesting process may be blocked
              may fail with error code
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
Four Conditions for Deadlock

   Mutual exclusion condition
                 each resource assigned to 1 process or is available
   Hold and wait condition
                 process holding resources can request additional
   No preemption condition
                 previously granted resources cannot forcibly taken away
   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
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
Deadlock Modeling (3)

Strategies for dealing with Deadlocks
           just ignore the problem altogether
           detection and recovery
           dynamic avoidance
                   careful resource allocation
           prevention
                   negating one of the four necessary conditions
Deadlock Modeling (4)
Deadlock Modeling (5)
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
Detection with One Resource of Each
                   Type (1)

   Note the resource ownership and requests
   A cycle can be found within the graph, denoting
    deadlock
Detection with One Resource of Each
               Type (2)

  Data structures needed by deadlock detection
                    algorithm
Detection with One Resource of Each
               Type (3)

   An example for the deadlock detection
                algorithm
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
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
Deadlock Avoidance
   Resource Trajectories

Two process resource trajectories
Safe and Unsafe States (1)

Demonstration that the state in (a) is safe
Safe and Unsafe States (2)

Demonstration that the sate in b is not safe
The Banker's Algorithm for a Single Resource


   Three resource allocation states
       safe
       safe
       unsafe
Banker's Algorithm for Multiple Resources


Example of banker's algorithm with multiple resources
Deadlock Prevention
        Attacking the Mutual Exclusion Condition

   Some devices (such as printer) can be spooled
       only the printer daemon uses printer resource
       thus deadlock for printer eliminated
   Not all devices can be spooled
   Principle:
       avoid assigning resource when not absolutely
        necessary
       as few processes as possible actually claim the
        resource
Attacking the Hold and Wait Condition

   Require processes to request resources before
    starting
        a process never has to wait for what it needs

   Problems
        may not know required resources at start of run
        also ties up resources other processes could be using

   Variation:
        process must give up all resources
        then request all immediately needed
Attacking the No Preemption Condition


   This is not a viable option
   Consider a process given the printer
       halfway through its job
       now forcibly take away printer
       !!??
Attacking the Circular Wait Condition (1)

   Normally ordered resources
   A resource graph
Attacking the Circular Wait Condition (1)

      Summary of approaches to deadlock
                 prevention
Other Issues
                     Two-Phase Locking

   Phase One
       process tries to lock all records it needs, one at a time
       if needed record found locked, start over
       (no real work done in phase one)
   If phase one succeeds, it starts second phase,
       performing updates
       releasing locks
   Note similarity to requesting all resources at once
   Algorithm works where programmer can arrange
       program can be stopped, restarted
Nonresource Deadlocks

   Possible for two processes to deadlock
       each is waiting for the other to do some task
   Can happen with semaphores
       each process required to do a down() on two
        semaphores (mutex and another)
       if done in wrong order, deadlock results
Starvation

   Algorithm to allocate a resource
       may be to give to shortest job first

   Works great for multiple short jobs in a system

   May cause long job to be postponed indefinitely
       even though not blocked

   Solution:
       First-come, first-serve policy
Pustaka

   Avi Silberschatz, "Operating System Concepts"
   http://codex.cs.yale.edu/avi/os-
    book/OS8/os8j/index.html
   Andrew Tanenbaum, "Modern Operating
    Systems"
   http://www.cs.vu.nl/~ast/books/mos2/
   Harvey Deitel, "Operating Systems"
   http://cs.nyu.edu/~yap/classes/os/resources/origin_of_
    PV.html
   tjerdastangkas.blogspot.com/search/label/ikh311

Contenu connexe

Tendances

Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating systemAli Haider
 
Deadlock in Distributed Systems
Deadlock in Distributed SystemsDeadlock in Distributed Systems
Deadlock in Distributed SystemsPritom Saha Akash
 
Deadlock- Operating System
Deadlock- Operating SystemDeadlock- Operating System
Deadlock- Operating SystemRajan Shah
 
Mca ii os u-3 dead lock & io systems
Mca  ii  os u-3 dead lock & io systemsMca  ii  os u-3 dead lock & io systems
Mca ii os u-3 dead lock & io systemsRai University
 
Deadlocks by wani zahoor
Deadlocks by wani zahoorDeadlocks by wani zahoor
Deadlocks by wani zahoorWani Zahoor
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating systemSara Ali
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating SystemAUST
 
Dead Lock In Operating Systems
Dead Lock In Operating SystemsDead Lock In Operating Systems
Dead Lock In Operating Systemstotallooser
 

Tendances (20)

Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating system
 
Deadlock in Distributed Systems
Deadlock in Distributed SystemsDeadlock in Distributed Systems
Deadlock in Distributed Systems
 
Operating system - Deadlock
Operating system - DeadlockOperating system - Deadlock
Operating system - Deadlock
 
Deadlock- Operating System
Deadlock- Operating SystemDeadlock- Operating System
Deadlock- Operating System
 
OS - Deadlock
OS - DeadlockOS - Deadlock
OS - Deadlock
 
Sucet os module_3_notes
Sucet os module_3_notesSucet os module_3_notes
Sucet os module_3_notes
 
Mca ii os u-3 dead lock & io systems
Mca  ii  os u-3 dead lock & io systemsMca  ii  os u-3 dead lock & io systems
Mca ii os u-3 dead lock & io systems
 
Deadlocks by wani zahoor
Deadlocks by wani zahoorDeadlocks by wani zahoor
Deadlocks by wani zahoor
 
Deadlock
DeadlockDeadlock
Deadlock
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
 
Dead Lock
Dead LockDead Lock
Dead Lock
 
Dead Lock In Operating Systems
Dead Lock In Operating SystemsDead Lock In Operating Systems
Dead Lock In Operating Systems
 
Deadlock Presentation
Deadlock PresentationDeadlock Presentation
Deadlock Presentation
 
Deadlock
DeadlockDeadlock
Deadlock
 
O ssvv62015
O ssvv62015O ssvv62015
O ssvv62015
 
Dead lock
Dead lockDead lock
Dead lock
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Deadlocks
Deadlocks Deadlocks
Deadlocks
 

En vedette

Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating systemMidhun Sankar
 
Corporate Fact Finder
Corporate Fact FinderCorporate Fact Finder
Corporate Fact Finderericmaher
 
The Dawn
The DawnThe Dawn
The DawnRuthEA
 
Pleno municipal infantil 2012
Pleno municipal infantil 2012Pleno municipal infantil 2012
Pleno municipal infantil 2012XXX XXX
 
CBI Presentation March 2011
CBI Presentation March 2011CBI Presentation March 2011
CBI Presentation March 2011thess1121
 
Master Refined Staging Pp
Master Refined Staging PpMaster Refined Staging Pp
Master Refined Staging PpMonicaObershaw
 
Focus 1 - construirea unui software functional, utilizabil si intuitiv
Focus 1 - construirea unui software functional, utilizabil si intuitivFocus 1 - construirea unui software functional, utilizabil si intuitiv
Focus 1 - construirea unui software functional, utilizabil si intuitivValentin Bora
 
B2: The OpenSplice BlendBox
B2: The OpenSplice BlendBoxB2: The OpenSplice BlendBox
B2: The OpenSplice BlendBoxAngelo Corsaro
 
Ugliest Nhl Jerseys
Ugliest Nhl JerseysUgliest Nhl Jerseys
Ugliest Nhl Jerseyssteve0965
 
Los primeros años_el_bienestar_infantil_y_el_papel_de_las_políticas_públicas
Los primeros años_el_bienestar_infantil_y_el_papel_de_las_políticas_públicasLos primeros años_el_bienestar_infantil_y_el_papel_de_las_políticas_públicas
Los primeros años_el_bienestar_infantil_y_el_papel_de_las_políticas_públicasPepe Jara Cueva
 
Dinamiche evolutive del settore agrituristico in Italia
Dinamiche evolutive del settore agrituristico in ItaliaDinamiche evolutive del settore agrituristico in Italia
Dinamiche evolutive del settore agrituristico in ItaliaJacopo Zurlo
 
PHP & XML: SimpleXML, DOMDocument
PHP & XML: SimpleXML, DOMDocumentPHP & XML: SimpleXML, DOMDocument
PHP & XML: SimpleXML, DOMDocumentValentin Bora
 

En vedette (20)

Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Deadlock ppt
Deadlock ppt Deadlock ppt
Deadlock ppt
 
Lect05
Lect05Lect05
Lect05
 
Sph 107 Ch16
Sph 107 Ch16Sph 107 Ch16
Sph 107 Ch16
 
Corporate Fact Finder
Corporate Fact FinderCorporate Fact Finder
Corporate Fact Finder
 
The Dawn
The DawnThe Dawn
The Dawn
 
Pronunciation
PronunciationPronunciation
Pronunciation
 
Pleno municipal infantil 2012
Pleno municipal infantil 2012Pleno municipal infantil 2012
Pleno municipal infantil 2012
 
PM Services
PM ServicesPM Services
PM Services
 
CBI Presentation March 2011
CBI Presentation March 2011CBI Presentation March 2011
CBI Presentation March 2011
 
Master Refined Staging Pp
Master Refined Staging PpMaster Refined Staging Pp
Master Refined Staging Pp
 
Focus 1 - construirea unui software functional, utilizabil si intuitiv
Focus 1 - construirea unui software functional, utilizabil si intuitivFocus 1 - construirea unui software functional, utilizabil si intuitiv
Focus 1 - construirea unui software functional, utilizabil si intuitiv
 
Tle4904 343973
Tle4904 343973Tle4904 343973
Tle4904 343973
 
B2: The OpenSplice BlendBox
B2: The OpenSplice BlendBoxB2: The OpenSplice BlendBox
B2: The OpenSplice BlendBox
 
Ugliest Nhl Jerseys
Ugliest Nhl JerseysUgliest Nhl Jerseys
Ugliest Nhl Jerseys
 
Al- Andalus
Al- AndalusAl- Andalus
Al- Andalus
 
Los primeros años_el_bienestar_infantil_y_el_papel_de_las_políticas_públicas
Los primeros años_el_bienestar_infantil_y_el_papel_de_las_políticas_públicasLos primeros años_el_bienestar_infantil_y_el_papel_de_las_políticas_públicas
Los primeros años_el_bienestar_infantil_y_el_papel_de_las_políticas_públicas
 
Dinamiche evolutive del settore agrituristico in Italia
Dinamiche evolutive del settore agrituristico in ItaliaDinamiche evolutive del settore agrituristico in Italia
Dinamiche evolutive del settore agrituristico in Italia
 
HC Vrchlabí
HC VrchlabíHC Vrchlabí
HC Vrchlabí
 
PHP & XML: SimpleXML, DOMDocument
PHP & XML: SimpleXML, DOMDocumentPHP & XML: SimpleXML, DOMDocument
PHP & XML: SimpleXML, DOMDocument
 

Similaire à ikh311-05

FP 202 Chapter 2 - Part 3
FP 202 Chapter 2 - Part 3FP 202 Chapter 2 - Part 3
FP 202 Chapter 2 - Part 3rohassanie
 
Deadlock in operating systems
Deadlock in operating systemsDeadlock in operating systems
Deadlock in operating systemsjamunaashok
 
Kcd226 Sistem Operasi Lecture05
Kcd226 Sistem Operasi Lecture05Kcd226 Sistem Operasi Lecture05
Kcd226 Sistem Operasi Lecture05Cahyo Darujati
 
3 (1) [Autosaved].ppt
3 (1) [Autosaved].ppt3 (1) [Autosaved].ppt
3 (1) [Autosaved].pptamadayshwan
 
Deadlockpresentation.pptx
Deadlockpresentation.pptxDeadlockpresentation.pptx
Deadlockpresentation.pptxKARMVIR6
 
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.pptxsvulasal
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating SystemSanthiNivas
 
Deadlocks prefinal
Deadlocks prefinalDeadlocks prefinal
Deadlocks prefinalmarangburu42
 
Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456marangburu42
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlockstech2click
 

Similaire à ikh311-05 (20)

Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
 
3 (2).ppt
3 (2).ppt3 (2).ppt
3 (2).ppt
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
FP 202 Chapter 2 - Part 3
FP 202 Chapter 2 - Part 3FP 202 Chapter 2 - Part 3
FP 202 Chapter 2 - Part 3
 
Deadlock in operating systems
Deadlock in operating systemsDeadlock in operating systems
Deadlock in operating systems
 
Kcd226 Sistem Operasi Lecture05
Kcd226 Sistem Operasi Lecture05Kcd226 Sistem Operasi Lecture05
Kcd226 Sistem Operasi Lecture05
 
3 (1) [Autosaved].ppt
3 (1) [Autosaved].ppt3 (1) [Autosaved].ppt
3 (1) [Autosaved].ppt
 
Deadlockpresentation.pptx
Deadlockpresentation.pptxDeadlockpresentation.pptx
Deadlockpresentation.pptx
 
Module3
Module3Module3
Module3
 
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
 
OS-Part-06.pdf
OS-Part-06.pdfOS-Part-06.pdf
OS-Part-06.pdf
 
Chapter06
Chapter06Chapter06
Chapter06
 
Ch 4 deadlock
Ch 4 deadlockCh 4 deadlock
Ch 4 deadlock
 
10. deadlock
10. deadlock10. deadlock
10. deadlock
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlocks prefinal
Deadlocks prefinalDeadlocks prefinal
Deadlocks prefinal
 
Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlocks
 

Plus de Anung Ariwibowo (20)

isd314-06-association-mining
isd314-06-association-miningisd314-06-association-mining
isd314-06-association-mining
 
ikp213-unifikasi
ikp213-unifikasiikp213-unifikasi
ikp213-unifikasi
 
ikp213-06-horn-clause
ikp213-06-horn-clauseikp213-06-horn-clause
ikp213-06-horn-clause
 
ikp213-01-pendahuluan
ikp213-01-pendahuluanikp213-01-pendahuluan
ikp213-01-pendahuluan
 
ikd312-05-sqlite
ikd312-05-sqliteikd312-05-sqlite
ikd312-05-sqlite
 
ikd312-05-kalkulus-relasional
ikd312-05-kalkulus-relasionalikd312-05-kalkulus-relasional
ikd312-05-kalkulus-relasional
 
ikd312-04-aljabar-relasional
ikd312-04-aljabar-relasionalikd312-04-aljabar-relasional
ikd312-04-aljabar-relasional
 
ikd312-03-design
ikd312-03-designikd312-03-design
ikd312-03-design
 
ikd312-02-three-schema
ikd312-02-three-schemaikd312-02-three-schema
ikd312-02-three-schema
 
ikp213-02-pendahuluan
ikp213-02-pendahuluanikp213-02-pendahuluan
ikp213-02-pendahuluan
 
ikh311-08
ikh311-08ikh311-08
ikh311-08
 
ikh311-07
ikh311-07ikh311-07
ikh311-07
 
ikh311-06
ikh311-06ikh311-06
ikh311-06
 
ikp321-svn
ikp321-svnikp321-svn
ikp321-svn
 
ikh311-04
ikh311-04ikh311-04
ikh311-04
 
ikp321-05
ikp321-05ikp321-05
ikp321-05
 
imsakiyah-jakarta-1433-09
imsakiyah-jakarta-1433-09imsakiyah-jakarta-1433-09
imsakiyah-jakarta-1433-09
 
ikh311-03
ikh311-03ikh311-03
ikh311-03
 
ikp321-04
ikp321-04ikp321-04
ikp321-04
 
ikp321-03
ikp321-03ikp321-03
ikp321-03
 

Dernier

Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 

Dernier (20)

Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 

ikh311-05

  • 1. Sistem Operasi IKH311 Deadlock
  • 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 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
  • 4. Resources (2)  Sequence of events required to use a resource  request the resource  use the resource  release the resource  Must wait if request is denied  requesting process may be blocked  may fail with error code
  • 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
  • 6. Four Conditions for Deadlock  Mutual exclusion condition  each resource assigned to 1 process or is available  Hold and wait condition  process holding resources can request additional  No preemption condition  previously granted resources cannot forcibly taken away  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
  • 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
  • 8. Deadlock Modeling (3) Strategies for dealing with Deadlocks  just ignore the problem altogether  detection and recovery  dynamic avoidance  careful resource allocation  prevention  negating one of the four necessary conditions
  • 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
  • 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
  • 13. Detection with One Resource of Each Type (2) Data structures needed by deadlock detection algorithm
  • 14. Detection with One Resource of Each Type (3) An example for the deadlock detection algorithm
  • 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
  • 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
  • 17. Deadlock Avoidance Resource Trajectories Two process resource trajectories
  • 18. Safe and Unsafe States (1) Demonstration that the state in (a) is safe
  • 19. Safe and Unsafe States (2) Demonstration that the sate in b is not safe
  • 20. The Banker's Algorithm for a Single Resource  Three resource allocation states  safe  safe  unsafe
  • 21. Banker's Algorithm for Multiple Resources Example of banker's algorithm with multiple resources
  • 22. Deadlock Prevention Attacking the Mutual Exclusion Condition  Some devices (such as printer) can be spooled  only the printer daemon uses printer resource  thus deadlock for printer eliminated  Not all devices can be spooled  Principle:  avoid assigning resource when not absolutely necessary  as few processes as possible actually claim the resource
  • 23. Attacking the Hold and Wait Condition  Require processes to request resources before starting  a process never has to wait for what it needs  Problems  may not know required resources at start of run  also ties up resources other processes could be using  Variation:  process must give up all resources  then request all immediately needed
  • 24. Attacking the No Preemption Condition  This is not a viable option  Consider a process given the printer  halfway through its job  now forcibly take away printer  !!??
  • 25. Attacking the Circular Wait Condition (1)  Normally ordered resources  A resource graph
  • 26. Attacking the Circular Wait Condition (1) Summary of approaches to deadlock prevention
  • 27. Other Issues Two-Phase Locking  Phase One  process tries to lock all records it needs, one at a time  if needed record found locked, start over  (no real work done in phase one)  If phase one succeeds, it starts second phase,  performing updates  releasing locks  Note similarity to requesting all resources at once  Algorithm works where programmer can arrange  program can be stopped, restarted
  • 28. Nonresource Deadlocks  Possible for two processes to deadlock  each is waiting for the other to do some task  Can happen with semaphores  each process required to do a down() on two semaphores (mutex and another)  if done in wrong order, deadlock results
  • 29. Starvation  Algorithm to allocate a resource  may be to give to shortest job first  Works great for multiple short jobs in a system  May cause long job to be postponed indefinitely  even though not blocked  Solution:  First-come, first-serve policy
  • 30. Pustaka  Avi Silberschatz, "Operating System Concepts"  http://codex.cs.yale.edu/avi/os- book/OS8/os8j/index.html  Andrew Tanenbaum, "Modern Operating Systems"  http://www.cs.vu.nl/~ast/books/mos2/  Harvey Deitel, "Operating Systems"  http://cs.nyu.edu/~yap/classes/os/resources/origin_of_ PV.html  tjerdastangkas.blogspot.com/search/label/ikh311