A Resource Allocation Graph (RAG) is a directed graph used by the OS to model the allocation of resources to processes and to detect or prevent deadlocks. By representing requests and assignments explicitly, the OS can ensure that it never enters a state in which a cycle—and hence a potential deadlock—exists.


1. RAG Components


2. Cycle Detection and Deadlock


3. Preventing Deadlocks via RAG Acyclicity To prevent deadlocks, the OS enforces that the RAG remain acyclic at all times. The high-level algorithm is:

  1. On a resource request Pᵢ → Rⱼ:
  2. Decision:

By never allowing the RAG to become cyclic, the OS guarantees that deadlocks cannot occur.


4. Illustrative Example