1 / 17

ITFN 2601 Introduction to Operating Systems

ITFN 2601 Introduction to Operating Systems. Lecture 6 Deadlock Deadlock Recovery. Agenda. What is a Resource? Deadlock Defined Conditions for Deadlock Resource Allocation Graphs Dealing with Deadlock. Resources. An object granted Hardware (disk, cpu)

carver
Download Presentation

ITFN 2601 Introduction to Operating Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ITFN 2601Introduction to Operating Systems Lecture 6 Deadlock Deadlock Recovery

  2. Agenda • What is a Resource? • Deadlock Defined • Conditions for Deadlock • Resource Allocation Graphs • Dealing with Deadlock

  3. Resources • An object granted • Hardware (disk, cpu) • Piece of Information (memory, record in DB) • Preemptable & non-preemptable

  4. Utilizing a Resource • Request resource • Use Resource • Release resource • Use a semaphore/mutex to get/release lock on resource

  5. Deadlock Defined • From our childhood… • I’ve got the ball and want the bat • You’ve got the bat and want the ball • “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.”

  6. Conditions for Deadlock • Mutual exclusion of resource • Hold and Wait (processes with a resource can request other resources) • Non-preemptable resources • Circular wait (chain of processes in wait) • See RAGs (next slide)

  7. Resource Allocation Graphs • Figure 6-3 D A S T U R B C Process Aholdingresource R Process Brequestingresource S Circularity = Deadlock

  8. Dealing with Deadlock • Ostrich Algorithm (today) • Detection & Recovery (today) • Dynamic Avoidance (next lecture) • Prevention (next lecture)

  9. Ostrich Algorithm • Stick your head in the sand and pretend there is no problem at all • What is the typical use of the system? • What is the probability of deadlock? • Do the costs associated with dealing w/ deadlock outweigh the benefits?

  10. Detection & Recovery • One resource of each type • Multiple resource of each type • Preemption • Rollback • Killing Processes

  11. Detection (1 resource) • Detect cycle in RAG • Use a directed graph • Utilize an optimized cycle detection algorithm – speed essential!

  12. Detection (multiple resource) • “Forget about it”

  13. OK, Now What? • Once we’ve detected deadlock… • Handle it • Preemption • Rollback • Killing Processes

  14. Preemption • Not always possible • Highly dependant upon the resource • Typically associated w/ hardware resources • Some examples • Suspending a large print job • CD-burner

  15. Rollback • Save the state of each process periodically (checkpoint) • Restore the process w/ the needed resource to an earlier checkpoint (before it acquired the resource) • Then the resource is now available • Drawback – “rolled back” process loses work

  16. Killing Processes • Again, not always an option • DB transactions cannot always be killed midway through! • Kill process to free up resource

  17. Summary • Resources can be preeptable & nonpreemptable • Deadlock can cause processes to halt (stop making progress) • We can detect deadlock • RAGs are quite useful • Ostrich algorithm quite popular

More Related