OS - Chapter 4
OS - Chapter 4
OS - Chapter 4
guarantee one
Example
Fig: Resource allocation graph with a deadlock Fig: Resource allocation graph with a cycle but no deadlock
Deadlock handling methods
• Prevention: it means to design such a system which violate
atleast one of the four necessary condition of deadlock and
ensure that deadlock should not occur.
• Avoidance: System maintains a set of data using which it takes a
decision whether to entertain a new request or not, to be in safe
state.
• Detection & recovery: In this we wait untill the deadlock occurs
and once we detect it, we recover from it.
• Ignorance: We ignore the problem as if it does not exist.
Deadlock Prevention
Mutual Exclusion:
• If a resource is assigned to more than one process, i.e., if a
resource is made sharable then deadlock will not occur
Windows 10
Single Instance of Each Resource Type
•If each resource category has a single instance, then we can use a
variation of the resource-allocation graph known as a wait-for
graph.
•A wait-for graph can be constructed from a resource-allocation
graph by eliminating the resources and collapsing the associated
edges, as shown in the figure below.
•An arc from Pi to Pj in a wait-for graph indicates that process Pi is
waiting for a resource that process Pj is currently holding.
•As before, cycles in the wait-for graph indicate deadlocks.
•This algorithm must maintain the wait-for graph, and periodically
search it for cycles.
Single Instance of Each Resource Type