Single Instance of Each Resource Type
Q2. What happens when a Single Instance of Each Resource Type is present?
Ans.
Maintain wait for graph
Node are processes
Pi → Pj,
if Pi is waiting for Pj.
Invoke an algorithm that searches for cycle in the graph. If there is a cycle, there exists a deadlock.
An algorithm to detect a cycle in the graph requires an order of n2 operations, where n=number of vertices or processes in the graph.
Figure: Resource Allocation Graph
Note:
- Process(P) to Resource(R) is a Request.
- Request (R) to Process (P) is a Assignment.
Figure: Wait for Graph