
Deadlock_BankersAlgo
Presentation
•
Computers
•
University
•
Practice Problem
•
Hard
Pushpendra Pateriya
Used 3+ times
FREE Resource
6 Slides • 4 Questions
1
Banker's Algorithm
2
Banker's Algorithm
The Banker's algorithm is a resource allocation and deadlock avoidance algorithm used in operating systems.
It was developed by Edsger Dijkstra in 1965.
The algorithm helps prevent deadlock in a system by allowing processes to request resources while ensuring that resources are allocated in a safe and non-blocking manner.
It is commonly used in multi-process, multi-resource systems, such as computer systems and operating systems.
3
Banker's Algorithm
The following data structures, where n is the number of processes in the system and m is the number of resource types:
Available. A vector of length m indicates the number of available resources of each type. If Available[j] equals k, then k instances of resource type Rj are available.
Max. An n × m matrix defines the maximum demand of each process.
If Max[i][j] equals k, then process Pi may request at most k instances of resource type Rj .
Allocation. An n × m matrix defines the number of resources of each type currently allocated to each process. If Allocation[i][j] equals k, then process Pi is currently allocated k instances of resource type Rj .
Need. An n × m matrix indicates the remaining resource need of each process. If Need[i][j] equals k, then process Pi may need k more instances of resource type Rj to complete its task.
Need[i][j] = Max[i][j] − Allocation[i][j].
4
Safety Algorithm
1. Let Work and Finish be vectors of length m and n, respectively. Initialize
Work = Available and Finish[i] = false for i = 0, 1, ..., n − 1.
2. Find an index i such that both
a. Finish[i] == false
b. Needi ≤ Work
If no such i exists, go to step 4.
3. Work = Work + Allocationi
Finish[i] = true
Go to step 2.
4. If Finish[i] == true for all i, then the system is in a safe state.
Note: This algorithm may require an order of m × n2 operations to determine whether
a state is safe.
5
Resource-Request Algorithm
Let Requesti be the request vector for process Pi .
If Requesti [j] == k, then process Pi wants k instances of resource type Rj . When a request for resources is made by process Pi, the following actions are taken:
If Requesti ≤ Needi , go to step 2. Otherwise, raise an error condition, since the process has exceeded its maximum claim.
If Requesti ≤ Available, go to step 3. Otherwise, Pi must wait, since the resources are not available.
Have the system pretend to have allocated the requested resources to process Pi by modifying the state as follows:
Available = Available–Requesti ;
Allocationi = Allocationi + Requesti ;
Needi = Needi –Requesti ;
If the resulting resource-allocation state is safe, the transaction is completed, and process Pi is allocated its resources. However, if the new state is unsafe, then Pi must wait for Requesti , and the old resource-allocation state is restored.
6
Example
Consider a system with five processes P0 through P4 and three resource types A, B, and C. Resource type A has ten instances, resource type B has five instances, and resource type C has seven instances. Suppose that, at time T0, the following snapshot of the system has been taken:
The system is currently in a safe state or not?
7
Multiple Choice
In the Banker's algorithm, which data structures are used to keep track of available, maximum, and allocated resources?
Stacks
Linked lists
Queues
Arrays
8
Multiple Choice
What is the purpose of the safety check in the Banker's algorithm?
To allocate resources to a process
To check if a process has enough resources
To ensure that resource allocation won't lead to deadlock
To terminate processes
9
Multiple Choice
When a process makes a resource request in the Banker's algorithm, what must be checked before granting the request?
If the process has enough money
If the process has the highest priority
If the process is the only one running
If the requested resources are available and the state remains safe
10
Multiple Choice
What happens if a resource request in the Banker's algorithm cannot be satisfied without violating safety?
The process is terminated
The request is granted anyway
The process is paused until the resources become available
The request is denied
Banker's Algorithm
Show answer
Auto Play
Slide 1 / 10
SLIDE
Similar Resources on Wayground
9 questions
Marketing Mix
Presentation
•
University
3 questions
Digital Tools
Presentation
•
University
7 questions
Food Mall - Induction Module 1
Presentation
•
KG - University
7 questions
unittest
Presentation
•
University
7 questions
Parts of a Computer
Presentation
•
University
7 questions
Magnetic Storage
Presentation
•
University
6 questions
C++ Comments
Presentation
•
University
3 questions
Midterm Exam Feedback
Presentation
•
University
Popular Resources on Wayground
11 questions
Hallway & Bathroom Expectations
Quiz
•
6th - 8th Grade
10 questions
HCS SCI 03 Summer School Assessment 2
Quiz
•
3rd Grade
11 questions
Home Scope
Quiz
•
7th - 8th Grade
12 questions
2026 TAP Technology in the Classroom
Presentation
•
Professional Development
15 questions
HCS SCI 05 Summer School Assessment 2 Review
Quiz
•
5th Grade
15 questions
HCS SCI 04 Summer School Review 2
Quiz
•
4th Grade
59 questions
Geometry Unit 3 Review
Quiz
•
9th - 12th Grade
14 questions
FAST ELA READING SMAPLE TEST MATERIALS
Passage
•
3rd Grade