
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
7 questions
PCIT21 WEEK 2
Presentation
•
University
7 questions
Python
Presentation
•
University
6 questions
Week 3 CAD 154
Presentation
•
University
6 questions
EDUC 207 -1
Presentation
•
University
8 questions
messor review
Presentation
•
University
8 questions
Deployment Models
Presentation
•
University
9 questions
Preparing Your Strategies for TTS2233
Presentation
•
University
6 questions
Web Technologies
Presentation
•
University
Popular Resources on Wayground
6 questions
Secondary Safety Quiz
Presentation
•
9th - 12th Grade
10 questions
MyPath Diagnostic Overview
Presentation
•
6th - 8th Grade
20 questions
Lab Safety Quiz
Quiz
•
6th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Adding and Subtracting Decimals
Quiz
•
5th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade
21 questions
Lab Safety
Quiz
•
10th Grade
Discover more resources for Computers
20 questions
Disney Trivia
Quiz
•
University
20 questions
Brand Trivia
Quiz
•
9th Grade - University
10 questions
Would you rather...
Quiz
•
KG - University
21 questions
Mapa países hispanohablantes
Quiz
•
1st Grade - University
10 questions
Spanish Greetings and Goodbyes!
Presentation
•
6th Grade - University
12 questions
CE 2b Early Documents Review
Quiz
•
7th Grade - University
30 questions
Multiplying and Dividing Integers
Quiz
•
6th Grade - University
13 questions
Back to School
Quiz
•
KG - University