Which Data Structure Is Used in Banker’s Algorithm?


Heather Bennett

The Banker’s algorithm is a resource allocation and deadlock avoidance algorithm used in operating systems. It ensures that the system can allocate resources to processes in a safe manner, preventing deadlocks from occurring. To understand which data structure is used in the Banker’s algorithm, let’s dive into the details.

Resource Allocation and Deadlock Avoidance

Before we discuss the data structure used in the Banker’s algorithm, let’s briefly understand resource allocation and deadlock avoidance.

Resource Allocation:

Resource allocation refers to the process of assigning resources to processes in a computer system. These resources can be anything from memory to CPU time or I/O devices. The goal of resource allocation is to ensure efficient utilization of resources while satisfying the requirements of each process.

Deadlock Avoidance:

A deadlock occurs when two or more processes are unable to proceed because each is waiting for a resource held by another process. Deadlocks can lead to system instability and affect overall performance. Deadlock avoidance aims to prevent deadlocks from happening by carefully managing resource allocation.

Data Structure Used in Banker’s Algorithm

The Banker’s algorithm utilizes several data structures to manage resource allocation and avoid deadlocks. The primary data structure used is called the resource-allocation graph. This graph represents the current state of resource allocation in the system.

Resource-Allocation Graph

  • The resource-allocation graph consists of two types of nodes: process nodes and resource nodes.
  • Process nodes represent individual processes in the system, while resource nodes represent different types of resources available.
  • The graph contains edges that represent the allocation and request relationships between processes and resources.

Let’s understand the different elements within the resource-allocation graph:

  • Process Nodes:
    • Each process node represents a process in the system.
    • It contains information about the resources allocated to that process and the resources it still needs to complete its execution.

  • Resource Nodes:
    • Each resource node represents a type of resource available in the system.
    • It contains information about the total number of instances of that resource and the number of instances currently allocated or available.

  • Edges:
    • The edges in the graph represent allocation and request relationships between processes and resources.
    • An edge from a process node to a resource node signifies that the process is currently allocated an instance of that resource.
    • An edge from a resource node to a process node indicates that the process has requested an additional instance of that resource.

Additional Data Structures

In addition to the resource-allocation graph, other data structures are used to implement the Banker’s algorithm:

  • Available Resource Vector:
  • The available resource vector keeps track of the number of available instances of each type of resource at any given time. It helps determine whether a particular request can be granted without leading to a deadlock.

  • Max Demand Matrix:
  • The max demand matrix represents the maximum number of instances of each resource that a process may request. It provides a way to compare the current allocation and future requests with the maximum allowed for each process.

  • Allocation Matrix:
  • The allocation matrix keeps track of the resources currently allocated to each process. It provides information about the resources in use and helps determine if a request can be granted without exceeding the maximum limits.

By utilizing these data structures, the Banker’s algorithm can safely allocate resources to processes while avoiding deadlocks. The resource-allocation graph allows for a visual representation of the system state, while additional data structures provide necessary information for decision-making.


The Banker’s algorithm is an essential tool in operating systems for resource allocation and deadlock avoidance. By utilizing data structures such as the resource-allocation graph, available resource vector, max demand matrix, and allocation matrix, it ensures that resources are allocated in a safe manner without causing deadlocks. Understanding these data structures is crucial for implementing and comprehending how the Banker’s algorithm works effectively.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy