SlideShare a Scribd company logo
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

More Related Content

What's hot

Dead Lock in operating system
Dead Lock in operating systemDead Lock in operating system
Dead Lock in operating system
Ali Haider
 
Deadlock in Distributed Systems
Deadlock in Distributed SystemsDeadlock in Distributed Systems
Deadlock in Distributed Systems
Pritom Saha Akash
 
Operating system - Deadlock
Operating system - DeadlockOperating system - Deadlock
Operating system - Deadlock
Shashank Yenurkar
 
Deadlock- Operating System
Deadlock- Operating SystemDeadlock- Operating System
Deadlock- Operating System
Rajan Shah
 
Sucet os module_3_notes
Sucet os module_3_notesSucet os module_3_notes
Sucet os module_3_notes
SRINIVASUNIVERSITYEN
 
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
Rai University
 
Deadlocks by wani zahoor
Deadlocks by wani zahoorDeadlocks by wani zahoor
Deadlocks by wani zahoor
Wani Zahoor
 
Deadlock
DeadlockDeadlock
Deadlock
Abhinaw Rai
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
ushabarad142
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
Sara Ali
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
AUST
 
Dead Lock
Dead LockDead Lock
Dead Lock
Ramasubbu .P
 
Dead Lock In Operating Systems
Dead Lock In Operating SystemsDead Lock In Operating Systems
Dead Lock In Operating Systems
totallooser
 
Deadlock Presentation
Deadlock PresentationDeadlock Presentation
Deadlock Presentation
salmancreation
 
O ssvv62015
O ssvv62015O ssvv62015
Dead lock
Dead lockDead lock
Dead lock
M_Javed Ashraf
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
lalithambiga kamaraj
 
Deadlocks
Deadlocks Deadlocks
Deadlocks
Shijin Raj P
 

What's hot (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
 

Viewers also liked

Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
Midhun Sankar
 
Corporate Fact Finder
Corporate Fact FinderCorporate Fact Finder
Corporate Fact Finderericmaher
 
The Dawn
The DawnThe Dawn
The DawnRuthEA
 
Pronunciation
PronunciationPronunciation
Pronunciation
Livemocha .com
 
Pleno municipal infantil 2012
Pleno municipal infantil 2012Pleno municipal infantil 2012
Pleno municipal infantil 2012XXX XXX
 
PM Services
PM ServicesPM Services
PM Services
Jeff Hendrick
 
CBI Presentation March 2011
CBI Presentation March 2011CBI Presentation March 2011
CBI Presentation March 2011
thess1121
 
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 intuitiv
Valentin Bora
 
Tle4904 343973
Tle4904 343973Tle4904 343973
Tle4904 343973
manthan patel
 
B2: The OpenSplice BlendBox
B2: The OpenSplice BlendBoxB2: The OpenSplice BlendBox
B2: The OpenSplice BlendBox
Angelo Corsaro
 
Ugliest Nhl Jerseys
Ugliest Nhl JerseysUgliest Nhl Jerseys
Ugliest Nhl Jerseys
steve0965
 
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
Pepe 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, DOMDocument
Valentin Bora
 

Viewers also liked (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
 

Similar to ikh311-05

Deadlocks
DeadlocksDeadlocks
Deadlocks
Dilum Bandara
 
3 (2).ppt
3 (2).ppt3 (2).ppt
3 (2).ppt
amadayshwan
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
Sakshi Tiwari
 
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 systems
jamunaashok
 
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].ppt
amadayshwan
 
Deadlockpresentation.pptx
Deadlockpresentation.pptxDeadlockpresentation.pptx
Deadlockpresentation.pptx
KARMVIR6
 
Module3
Module3Module3
Module3
dilshad begum
 
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
svulasal
 
OS-Part-06.pdf
OS-Part-06.pdfOS-Part-06.pdf
OS-Part-06.pdf
NguyenTienDungK17HL
 
Ch 4 deadlock
Ch 4 deadlockCh 4 deadlock
Ch 4 deadlock
madhuributani
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
SanthiNivas
 
Deadlock
DeadlockDeadlock
Deadlock
Rup Chowdhury
 
Deadlocks prefinal
Deadlocks prefinalDeadlocks prefinal
Deadlocks prefinal
marangburu42
 
Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456Deadlocksprefinal 161014115456
Deadlocksprefinal 161014115456
marangburu42
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlockstech2click
 

Similar to 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
 

More from 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
 

Recently uploaded

June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Ashish Kohli
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
NelTorrente
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 

Recently uploaded (20)

June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 

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