# Resource Allocation Graph – Resource Instance Management and  Advantages

## Resource Allocation Graph – Resource Instance Management and  Advantages

As we see in Banker’s algorithm that this algorithm helps in safe allocation of resources. Similarly, if we want to represents the state of the system in the form of a graph instead of using the banker’s algorithm’s table, then Resource Allocation Graph can be helpful. It is very easy to understand and represents resource allocation with the help of a graph. This kind of graph shows the allocation of resources, is called Resource Allocation Graph (RAG).

## Advantages of Resource Allocation Graph

1. It takes less time to understand the resource allocation via the Resource Allocation Graph.
2. Sometimes it is possible to see a deadlock directly with a glance by using Resource Allocation Graph, which is very difficult to understand by looking at the table.
3. Resource Allocation Graph helps us to understand the following main things;
1. Which resource is required by the process.
2. How many resources are required by the process?
3. How many resources are available
4. How many are allocated?

## Disadvantages of Resource Allocation Graph

It is better to store the resources allocation record in tables if the system contains many processes and resources and Resource Allocation Graphs are better when the system contains fewer processes and resources.

### How many types of Resource Allocation Graph edge exists?

There are two main types of edges in the Resource Allocation Graph.

Request Edge

Request Edge represents that a process is trying to request to get some resources.

Assign Edge

Assign Edge represents that a resource is allocated to the process and the process is enjoying the resource.

In figure 2, we can observe the following facts;

1. Process P1 is requesting for Resource R1 and R2 and P1 have no resource.
2. Process P2 is requesting Resource R3 and P2 is enjoying the resource R1(assigned).
3. Process P3 is requesting Resource R4 and P3 is enjoying the resource R2(assigned).
4. Process P4 is requesting for Resource R3 and R4, and P4 have no resource.

## Parts of Resource Allocation Graph

Resource Allocation Graph contains vertices and edges. In Resource Allocation Graph vertices are of two types.

### How many types of Resource Allocation Graph vertices?

There are two main types of resource allocation graph vertices.

1. Process Vertex
2. Resource Vertex

Process vertex

In Process vertex, the process can be represented with a circle. Every process will be represented as a process vertex.
Resource vertex

In Resource vertex, Every resource can be represented as a resource vertex.
Resource vertex is of two types;

1. Single instance type of resource
2. Multi-resource instance type resource

### Single resource instance

It represents a box and there will be one dot inbox to represent the one resource instance. So, we can say that the number of dots indicates how many resource instances are present of each resource type.

### Multi-resource instance

It also represents as a box, inside the box, there can be many dots and each of the dots represents the resource instance type.