Resource Allocation Graph (RAG) in Operating System
Last Updated :
26 Dec, 2024
A Resource Allocation Graph (RAG) is a visual way to understand how resources are assigned in an operating system. Instead of using only tables to show which resources are allocated, requested, or available, the RAG uses nodes and edges to clearly illustrate relationships between processes and their required resources.
Although the Banker’s algorithm which is known for deadlock avoidance often relies on tables for simplicity. RAGs primarily help in detecting deadlocks by visually representing the relationships between processes and resources, making it easier to identify potential deadlock conditions.
Resource Allocation Graph (RAG)
A Resource Allocation Graph shows which resources are held by which processes and which processes are waiting for specific types of resources. It’s a straightforward tool for visualizing potential deadlocks in an operating system since the graph can make deadlock situations more obvious than a table might. By using an RAG, you can see how resource allocation and requests affect the entire system. While tables are often better for large systems with many processes and resources, RAGs are ideal for smaller environments where a quick, visual understanding of resource management is more effective.
So, the resource allocation graph clearly shows the state of the system in terms of processes and resources, including how many resources are available, how many are allocated, and what each process needs. By visualizing this information as a graph, it can be easier to spot potential deadlocks than when looking at tables alone. However, tables are often more convenient for systems with many processes and resources, while RAGs are more helpful in smaller environments. As with any graph, a RAG uses vertices to represent processes and resources, and edges to connect them, creating a straightforward picture of resource allocation within the operating system.
Types of Vertices in RAG
In a Resource Allocation Graph, there are two types of vertices
1. Process Vertex: Every process will be represented as a process vertex. Generally, the process will be represented with a circle.
2. Resource Vertex: Every resource will be represented as a resource vertex. It is also two types:
- Single instance type resource: It represents a box, inside the box, there will be one dot. So the number of dots indicates how many instances are present of each resource type.
- Multi-resource instance type resource: It also represents as a box, inside the box, there will be many dots present.

Types of Edges in RAG
Now coming to the edges of RAG. There are two types of edges in RAG:
- Assign Edge: If you already assign a resource to a process then it is called Assign edge.
- Request Edge: A request edge represents that a process is currently requesting a resource. This is shown by an arrow from the process vertex to the resource vertex.

So, if a process is using a resource, an arrow is drawn from the resource node to the process node. If a process is requesting a resource, an arrow is drawn from the process node to the resource node.
Example 1 (Single Instances RAG)

If there is a cycle in the Resource Allocation Graph and each resource in the cycle provides only one instance, then the processes will be in deadlock. For example, if process P1 holds resource R1, process P2 holds resource R2 and process P1 is waiting for R2 and process P2 is waiting for R1, then process P1 and process P2 will be in deadlock.

Here’s another example, that shows Processes P1 and P2 acquiring resources R1 and R2 while process P3 is waiting to acquire both resources. In this example, there is no deadlock because there is no circular dependency. So cycle in single-instance resource type is the sufficient condition for deadlock.
Example 2 (Multi-instances RAG)

From the above example, it is not possible to say the RAG is in a safe state or in an unsafe state. So to see the state of this RAG, let’s construct the allocation matrix and request matrix.

- The total number of processes are three: P1, P2 & P3 and the total number of resources are two: R1 & R2.
- Allocation matrix
- For constructing the allocation matrix, just go to the resources and see to which process it is allocated.
- R1 is allocated to P1, therefore write 1 in allocation matrix and similarly, R2 is allocated to P2 as well as P3 and for the remaining element just write 0.
- Request matrix
- In order to find out the request matrix, you have to go to the process and see the outgoing edges.
- P1 is requesting resource R2, so write 1 in the matrix and similarly, P2 requesting R1 and for the remaining element write 0.
- So now available resource is = (0, 0).
- Checking deadlock (safe or not)

- So there is no deadlock in this RAG. Even though there is a cycle, still there is no deadlock. Therefore in multi-instance resource cycle is not sufficient condition for deadlock.

Above example is the same as the previous example except that, the process P3 requesting for resource R1. So the table becomes as shown in below.

So, the Available resource is = (0, 0), but requirement are (0, 1), (1, 0) and (1, 0). So you can’t fulfill any one requirement. Therefore, it is in deadlock. Therefore every cycle in a multi-instance resource type graph is not a deadlock. If there has to be a deadlock, there has to be a cycle. So in case of RAG with multi-instance resource type, the cycle is a necessary condition for deadlock but not sufficient.
GATE CS Corner Questions
Practicing the following questions will help you test your knowledge. All questions have been asked in GATE in previous years or in GATE Mock Tests. It is highly recommended that you practice them.
- GATE CS 2009, Question 60
- GATE CS 2014 (Set 1), Question 65
Conclusion
A Resource Allocation Graph is an essential visualization tool in operating systems that helps highlight how resources are allocated to various processes. By illustrating which resources are in use, which are available, and what each process needs, RAGs make it easier to detect congestion, identify potential deadlocks, and improve overall system efficiency. Although tables are effective for large, complex environments, RAGs offer a clear, intuitive approach to resource management, ensuring better performance and security within the operating system.
Frequently Asked Questions on Resource Allocation Graph – FAQ’s
What is a cycle in a resource allocation graph?
A cycle in a resource allocation graph is a closed sequence of processes and resources where each process is waiting for a resource currently held by the next process in the cycle.
What is the difference between resource allocation graph and wait for graph?
A resource allocation graph represents processes and resources as separate nodes with edges indicating allocation or requests, whereas a wait-for graph represents only processes, with edges showing one process waiting for another to release resources.
What is meant by resource allocation?
Resource allocation is the process of assigning available resources to processes according to their requirements. It ensures that processes obtain the necessary resources to execute efficiently without unnecessary delays.
Our GATE 2026 Courses for CSE & DA offer live and recorded lectures from GATE experts, Quizzes, Subject-Wise Mock Tests, PYQs and practice questions, and Full-Length Mock Tests to ensure you’re well-prepared for the toughest questions.
Take the Three 90 Challenge! Complete 90% of the course in 90 days and earn a 90% refund. Stay motivated, track your progress, and make the most of your preparation time. Plus, enjoy exclusive features like:
--> All India Mock Test
--> Live GATE CSE & DA Mentorship Classes
--> Live Doubt Solving Sessions
Join now and stay ahead in your GATE 2026 journey!
Similar Reads
States of a Process in Operating Systems
In an operating system, a process is a program that is being executed. During its execution, a process goes through different states. Understanding these states helps us see how the operating system manages processes, ensuring that the computer runs efficiently. Please refer Process in Operating Sys
11 min read
CPU Scheduling in Operating Systems
CPU scheduling is a process used by the operating system to decide which task or process gets to use the CPU at a particular time. This is important because a CPU can only handle one task at a time, but there are usually many tasks that need to be processed. The following are different purposes of a
9 min read
Preemptive and Non-Preemptive Scheduling
In operating systems, scheduling is the method by which processes are given access the CPU. Efficient scheduling is essential for optimal system performance and user experience. There are two primary types of CPU scheduling: preemptive and non-preemptive. Understanding the differences between preemp
6 min read
Starvation and Aging in Operating Systems
Starvation occurs when a process in the OS runs out of resources because other processes are using it. This is a problem with resource management while Operating systems employ aging as a scheduling approach to keep them from starving. It is one of the most common scheduling algorithms in batch syst
7 min read
Introduction of System Call
A system call is a programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on. A system call is a way for programs to interact with the operating system. A computer program makes a system call when it requests the operating system's kern
11 min read
Difference between User Level thread and Kernel Level thread
User-level threads are threads that are managed entirely by the user-level thread library, without any direct intervention from the operating system's kernel, whereas, Kernel-level threads are threads that are managed directly by the operating system's kernel. In this article, we will see the overvi
5 min read
Introduction of Process Synchronization
Process Synchronization is used in a computer system to ensure that multiple processes or threads can run concurrently without interfering with each other. The main objective of process synchronization is to ensure that multiple processes access shared resources without interfering with each other a
10 min read
Critical Section in Synchronization
A critical section is a part of a program where shared resources like memory or files are accessed by multiple processes or threads. To avoid issues like data inconsistency or race conditions, synchronization techniques ensure that only one process or thread uses the critical section at a time. When
9 min read
Inter Process Communication (IPC)
Processes need to communicate with each other in many situations, for example, to count occurrences of a word in text file, output of grep command needs to be given to wc command, something like grep -o -i <word> <file> | wc -l. Inter-Process Communication or IPC is a mechanism that allo
5 min read
Semaphores in Process Synchronization
Semaphores are a tool used in operating systems to help manage how different processes (or programs) share resources, like memory or data, without causing conflicts. A semaphore is a special kind of synchronization data that can be used only through specific synchronization primitives. Semaphores ar
15+ min read
Mutex vs Semaphore
In the Operating System, Mutex and Semaphores are kernel resources that provide synchronization services (also known as synchronization primitives). Synchronization is required when multiple processes are executing concurrently, to avoid conflicts between processes using shared resources. In this ar
8 min read
Deadlock, Starvation, and Livelock
Prerequisite - Deadlock and Starvation Livelock occurs when two or more processes continually repeat the same interaction in response to changes in the other processes without doing any useful work. These processes are not in the waiting state, and they are running concurrently. This is different f
6 min read
Introduction of Deadlock in Operating System
A deadlock is a situation where a set of processes is blocked because each process is holding a resource and waiting for another resource acquired by some other process. In this article, we will discuss deadlock, its necessary conditions, etc. in detail. What is Deadlock?Deadlock is a situation in c
11 min read
Resource Allocation Graph (RAG) in Operating System
A Resource Allocation Graph (RAG) is a visual way to understand how resources are assigned in an operating system. Instead of using only tables to show which resources are allocated, requested, or available, the RAG uses nodes and edges to clearly illustrate relationships between processes and their
6 min read
Banker's Algorithm in Operating System
The Banker’s Algorithm is a resource allocation and deadlock avoidance algorithm that tests for safety by simulating the allocation for the predetermined maximum possible amounts of all resources, then makes an “s-state” check to test for possible activities, before deciding whether allocation shoul
15+ min read
Memory Allocation Techniques | Mapping Virtual Addresses to Physical Addresses
Prerequisite : Requirements of Memory Management System, Logical and Physical Address Memory Allocation Techniques:To store the data and to manage the processes, we need a large-sized memory and, at the same time, we need to access the data as fast as possible. But if we increase the size of memory,
5 min read
Paging in Operating System
Paging is a memory management scheme that eliminates the need for a contiguous allocation of physical memory. The process of retrieving processes in the form of pages from the secondary storage into the main memory is known as paging. The basic purpose of paging is to separate each procedure into pa
10 min read
Page Table Entries in Page Table
A Page Table is a data structure used by the operating system to keep track of the mapping between virtual addresses used by a process and the corresponding physical addresses in the system's memory. A Page Table Entry (PTE) is an entry in the Page Table that stores information about a particular pa
7 min read
Inverted Page Table in Operating System
Most Operating Systems implement a separate page table for each process, i.e. for the 'n' number of processes running on a Multiprocessing/ Timesharing Operating System, there is an 'n' number of page tables stored in the memory. Sometimes when a process is very large and it occupies virtual memory
7 min read
Segmentation in Operating System
A process is divided into Segments. The chunks that a program is divided into which are not necessarily all of the exact sizes are called segments. Segmentation gives the user's view of the process which paging does not provide. Here the user's view is mapped to physical memory. Types of Segmentatio
4 min read
Partition Allocation Methods in Memory Management
In the operating system, the following are four common memory management techniques. Single contiguous allocation: Simplest allocation method used by MS-DOS. All memory (except some reserved for OS) is available to a process. Partitioned allocation: Memory is divided into different blocks or partiti
4 min read
Non-Contiguous Allocation in Operating System
Non-contiguous allocation, also known as dynamic or linked allocation, is a memory allocation technique used in operating systems to allocate memory to processes that do not require a contiguous block of memory. In this technique, each process is allocated a series of non-contiguous blocks of memory
6 min read
Fixed (or static) Partitioning in Operating System
Fixed partitioning, also known as static partitioning, is one of the earliest memory management techniques used in operating systems. In this method, the main memory is divided into a fixed number of partitions at system startup, and each partition is allocated to a process. These partitions remain
8 min read
Variable (or Dynamic) Partitioning in Operating System
In operating systems, Memory Management is the function responsible for allocating and managing a computer’s main memory. The memory Management function keeps track of the status of each memory location, either allocated or free to ensure effective and efficient use of Primary Memory. Below are Memo
4 min read
Buddy System - Memory Allocation Technique
Static partition techniques are limited by having a fixed number of active processes, and space use may not be optimal. The buddy system is a memory allocation and management technique that uses power-of-two increments. Assume the memory size is 2U and a size of S is required. In this article, we ar
9 min read