1 / 18

CS 450 OPERATING SYSTEMS DEADLOCKS

CS 450 OPERATING SYSTEMS DEADLOCKS. Manju Muralidharan Priya. Objective. At the end of this presentation, you will know: What is a Deadlock? Preventing and Avoiding Deadlocks Detecting Deadlocks Recovery Schemes. What is a Deadlock?.

travis
Download Presentation

CS 450 OPERATING SYSTEMS DEADLOCKS

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. CS 450 OPERATING SYSTEMSDEADLOCKS Manju Muralidharan Priya

  2. Objective At the end of this presentation, you will know: • What is a Deadlock? • Preventing and Avoiding Deadlocks • Detecting Deadlocks • Recovery Schemes CS 561 Deadlocks

  3. What is a Deadlock? “ To get a job, you need experience. To gain experience you need a job” Definition: The permanent blocking of a set of processes that compete for the system resources or communicate with each other. CS 561 Deadlocks

  4. The Dining Philosopher’s Problem • 5 Philosophers • 5 Forks • All Philosophers need a left fork and a right fork to eat. • Deadlock : All philosophers reach for the left fork at the same time. CS 561 Deadlocks

  5. System Model • System has processes and resources • Processes can • Request & wait for a resource • Use the resource • Release the resource after use. • Deadlock: Each process is waiting for a resource being held by the other process. P1 Hold Request R1 R2 Hold Request P2 CS 561 Deadlocks

  6. Deadlock Characterization Conditions for a deadlock to occur • Mutual Exclusion : A resource can be used only by one process at a time. • Hold & Wait : A process can retain holds on resources while it waits for other. • No Preemption : No resource can be forcibly removed from a process holding it. • Circular Wait : Process 1 is waiting for Process 2 , Process 2 is waiting for Process 3 and Process 3 is waiting for process 1 All 4 of the above must happen at the same time for deadlock to occur. CS 561 Deadlocks

  7. Resource Allocation graphsDepicts the state of the system of resources and processes • Process • Resource and instances • Request from process to resource • Allocated instance Pi Ri Pi Ri Ri Pi CS 561 Deadlocks

  8. Resource Allocation Graph with cycle and deadlock • Resource Allocation Graph with cycle and no deadlock P2 R3 R1 R1 P3 P1 P2 P3 P1 R2 R2 R4 P3 CS 561 Deadlocks

  9. Handling Deadlocks • Ostrich Algorithm • Pretend there is no problem • Deadlock Prevention • Stop the four conditions from happening • Deadlock Avoidance • Allow deadlock conditions • Calculate safe and unsafe states • Deadlock Detection • Allow the deadlock to happen • Recover from the deadlock Stop Deadlock from happening CS 561 Deadlocks

  10. Deadlock Prevention • Mutual Exclusion • Disallow mutual exclusion for sharable resources • Hold & Wait • Process requests all requires resources at one time. • Low resource utilization & Starvation • No Preemption • Process must let go of all holds before making a new request • Circular Wait • Define linear ordering on resources CS 561 Deadlocks

  11. Deadlock Avoidance • State of the system is calculated • Unsafe State : Deadlock may occur. • Safe State : Ample resource instances exist. • Denial of resource allocation happens if request causes unsafe state SAFE UNSAFE DEADLOCK O.S. can avoid deadlock. Only with luck will processes avoid deadlock. CS 561 Deadlocks

  12. Deadlock Avoidance contd. • Assume a simple model: • 3 Processes & 12 Magnetic tape drives. • The current state is as follows: The safe order of execution is <p1,p0,p2> The system enters an unsafe state when p2 requests and is allocated another tape. A safety algorithm is used to detect the safe state by calculating the needs of the processes and the amount of resource allocated. CS 561 Deadlocks

  13. Deadlock Avoidance contd. • When resource has only one instance: • Use resource allocation graph to detect cycles • When resource has multiple instances: • Cycles do not mean deadlocks • Use Banker’s algorithm • All processes must return resources within a finite amount of time. • Processes may have to wait for allocation CS 561 Deadlocks

  14. Deadlock Detection • Let the deadlock happen • Detect deadlock • For single instance resource : • Detect cycle with Resource Allocation Graph • For multiple instance resource keep track of: • Available resources • Allocated resources • Number of requests made • Recover from deadlock CS 561 Deadlocks

  15. Recovery Techniques • Abort all deadlocked processes. • Rollback deadlocked process to previous checkpoint and restart. • Abort deadlocked process successively till deadlock disappears. • Preempt deadlocked resources till deadlock disappears CS 561 Deadlocks

  16. Recovery Techniques contd. Criterion for aborting and preempting processes • Least consumption of processor time • Least amount of output produced • Most time remaining • Least total allocated resources • Lowest priority CS 561 Deadlocks

  17. Wrapping up… • There are strengths and weaknesses to all approaches • Use a different strategy in different situations depending on: • Memory • Internal resources • Process resources CS 561 Deadlocks

  18. THANK YOU CS 561 Deadlocks

More Related