
Deadlock_BankersAlgo
Presentation
•
Computers
•
University
•
Practice Problem
•
Hard
Pushpendra Pateriya
Used 3+ times
FREE Resource
6 Slides • 4 Questions
1
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
Show answer
Auto Play
Slide 1 / 10
SLIDE
Similar Resources on Wayground
11 questions
Robotics
Presentation
•
University
7 questions
Tech Trends 2023
Presentation
•
University
9 questions
Living in the IT Era Quiz No. 2
Presentation
•
University
6 questions
SQL SELECT Statement 2
Presentation
•
University
7 questions
Quiz Interactive
Presentation
•
University
7 questions
Pelatihan FPD
Presentation
•
KG
8 questions
Basic Terminologies and Algorithm Design
Presentation
•
University
8 questions
WEEK 4 Review
Presentation
•
University
Popular Resources on Wayground
10 questions
Safety Day 2026 – Student Review
Quiz
•
9th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
12 questions
Map Skills
Quiz
•
3rd Grade
22 questions
Continents and Oceans
Quiz
•
5th Grade
15 questions
Rounding Decimals
Quiz
•
5th Grade
Discover more resources for Computers
20 questions
Disney Trivia
Quiz
•
University
10 questions
Spanish Greetings and Goodbyes!
Presentation
•
6th Grade - University
20 questions
Physical or Chemical Change/Phases
Quiz
•
8th Grade - University
39 questions
Unit 7 Key Terms
Quiz
•
11th Grade - University
25 questions
SER and Subject Pronouns
Quiz
•
8th Grade - University
38 questions
Unit 6 Key Terms
Quiz
•
11th Grade - University
19 questions
Key Concepts in Buddhism
Quiz
•
University
0 questions
Cell Domain Basic Review (Biology)
Quiz
•
University