
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
8 questions
Untitled Lesson
Presentation
•
University
10 questions
MODAL VERB : CAN
Presentation
•
University
9 questions
Reading Strategies
Presentation
•
6th - 8th Grade
10 questions
Module 2 Chapter 4 Lecture 2
Presentation
•
University
9 questions
Breakeven Point
Presentation
•
University
7 questions
CSC186 - UML
Presentation
•
University
7 questions
SQL ORDER BY Keyword
Presentation
•
University
7 questions
IIS
Presentation
•
University
Popular Resources on Wayground
20 questions
Math Review
Quiz
•
3rd Grade
15 questions
Fast food
Quiz
•
7th Grade
20 questions
Context Clues
Quiz
•
6th Grade
20 questions
Inferences
Quiz
•
4th Grade
19 questions
Classifying Quadrilaterals
Quiz
•
3rd Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
10 questions
Identify Fractions, Mixed Numbers & Improper Fractions
Quiz
•
3rd - 4th Grade
Discover more resources for Computers
20 questions
Guess The App
Quiz
•
KG - Professional Dev...
11 questions
NFL Football logos
Quiz
•
KG - Professional Dev...
19 questions
Minecraft
Quiz
•
6th Grade - Professio...
40 questions
8th Grade Math Review
Quiz
•
8th Grade - University
20 questions
Block Buster Movies
Quiz
•
10th Grade - Professi...
10 questions
Would you rather...
Quiz
•
KG - University
40 questions
Flags of the World
Quiz
•
KG - Professional Dev...
14 questions
Superhero
Quiz
•
1st Grade - University