RAG is the abbreviation for Resource Allocation Graph in operating systems. RAG is a directed graph which can be used to represent the state of a system in the form of picture. Deadlocks can be described more precisely in terms of a directed graph(RAG).
The graph(V, E) consists a set of vertices which can be partitioned into two different types of nodes:-
-
Process vertices –
They represents the processes and are drawn as a circle, e.g.,{P1, P2, P3.....Pn}
-
Resource vertices –
These vertices represents the resources and are drawn as a square with dots in it, which represent the instance of resources, e.g.,{R1, R2, R3.....Rn}
Resource Allocation Graphs are drawn in order to see the allocation relations between the processes and Resources. Here, Processes are represented inside a circle whereas Resources are represented inside a square with dots inside it indicating the number of instances of resources.
RAG have two types of Edges, one which represents the assignment and other represents the wait of a process for a resource.
- A resource is assigned to a process if the tail of the arrow is attached to an instance to the resource and the head is attached to a process.
- A process is waiting for a resource if the tail of an arrow is attached to the process while the head is pointing towards the resource.
If RAG contains a cycle, then the system is in deadlock otherwise not.
Characteristics of RAG:
-
Pictorial representation –
RAG is the pictorial representation of the states of a system -
Deadlock detection –
Using RAG, we can easily detect that whether the system is in deadlock or not. -
Resources Information –
RAG contains all the information of resources and its instances that whether they are free or currently being used by any other processes. -
Processes Information –
RAG tells us about the processes that which process is holding which resource and which resource, it is requesting.
Advantages of RAG:
- It is very useful in deadlock detection.
- It is widely used in the Banker’s Algorithm.
- It is a pictorial representation of a system..
- Sometimes we can tell whether the system is in deadlock or not by just having a glance at the graph.
- It takes less time to understand the allocation of resources via RAG.
Disadvantages of RAG:
- RAG is useful when we have less number of processes and resources.
- With large number of resources or processes, it is better to store data in a table rather than RAG.
- If there are large number of resources or processes, then the graph will be difficult to understand and will become complex.