1 / 14

Deadlocks

Deadlocks. Deadlock handling . Deadlock prevention Deadlock avoidance Deadlock detection Deadlock recovery. How deadlocks arise. Conflicting need for resource by two or more processes All process are unable to proceed. Get A Get B Release B Release A. Get B Get A Release B

craig
Download Presentation

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. Deadlocks

  2. Deadlock handling • Deadlock prevention • Deadlock avoidance • Deadlock detection • Deadlock recovery

  3. How deadlocks arise • Conflicting need for resource by two or more processes • All process are unable to proceed

  4. Get A Get B Release B Release A Get B Get A Release B Release A Deadlock Example Precess P Process Q

  5. Four conditions for deadlocks • Mutual exclusion of resources • Hold and wait • A process can hold a resource and wait for another • No preemption • A process will release resources voluntarily • Circular wait • There is a circular wait among the processes

  6. Deadlock prevention • Make one of the four conditions false aways • No deadlock! • Which condition? Only circular wait condition is doable

  7. Make circular wait condition false always • Order all the resources • Processes can request resources that are ordered strictly higher than what they are holding • Can prove that there are cycles in wait for graph

  8. Deadlock avoidance • Allows more concurrency than prevention • A decision is made dynamically whether the current resource allocation request will potentially lead to a deadlock (if granted) • Needs knowledge of future resource needs

  9. Two rules of deadlock avoidance • Do not start a process if its demands might lead to a deadlock • Do not grant an incremental resource request to a process if doing so might lead to a deadlock

  10. Initial denial • R = (R1, R2, …, Rm) set of system resources; m types of resources • A = (V1, V2, …, Vm) available reources (not allocated to any process) at any time • Claim matrix; maximum requirement of each process for each resource • Current allocation matrix; what each process holds currently

  11. Relations • Ri = Vi + sum(A_ki) k going from 1 to n • C_kl <= R_i for all k, I • A_ki <= C_ki for all k, i • (Strong condition): Start a new process P_n+1 only if R_I >= C_(n+1)i+sum(C_ki) k going from 1 to n; for all i

  12. Resource allocation denial • Banker’s algorithm • Safe and unsafe states • Detect if a state is unsafe • Go from one safe state to another safe state

  13. Deadlock recovery • Forcibly terminate some processes to recover from deadlocks. • Deadlock breaking set: Set of processes, which when terminated, will lead to the other processes’ normal termination. • Cost of forcibly terminating a process

  14. Deadlock recovery Cont’d • Cost of deadlock breaking set: sum of the cost of aborting processes in the deadlock breaking set. • Optimal deadlock breaking set: Deadlock breaking set of least cost. • Finding the optimal deadlock breaking set is an NP-hard problem.

More Related