Resource-Allocation-Graph Algorithm
Resource-Allocation-Graph Algorithm (Deadlock Avoidance) This algorithm is used when: ✔ Each resource type has only one instance It is a modification of the regular resource-allocation graph used for deadlock detection, but here it is used for avoidance . Basic Idea The goal is: Never allow the system to enter an unsafe state. The algorithm checks whether granting a resource request would create a cycle in the graph. If granting the request creates a cycle → Unsafe → Deny request If no cycle is formed → Safe → Grant request Since each resource has only one instance: A cycle in the graph implies unsafe state (and potential deadlock). Types of Edges in This Algorithm In addition to the usual edges, we introduce a new edge type. (1) Request Edge (Ti → Rj) Thread Ti is requesting resource Rj. (2) Assignment Edge (Rj → Ti) Resource Rj is allocated to thread Ti. (3) Claim Edge (Ti → Rj) ← New Concept Represented as a dashed line Indicates thread ...