Questions tagged [bankers-algorithm]

It's a Resource allocation and deadlock avoidance algorithm. which states Maximum number of instances of each resource type the process can claim.

DEFINITION:

“The Banker’s algorithm is a resource allocation and deadlock avoidance algorithm developed by Edsger Dijkstra that tests for safety by simulating the allocation of predetermined maximum possible amounts of all resources, and then makes a “s-state” check to test for possible deadlock conditions for all other pending activities, before deciding whether allocation should be allowed to continue” – source Wikipedia.

WHY THE NAME BANKER'S?

“Like other algorithms, the Banker’s algorithm has some limitations when implemented. Specifically, it needs to know how much of each resource a process could possibly request. In most systems, this information is unavailable, making it impossible to implement the Banker’s algorithm.“ – source Wikipedia

DESIGN

“The Banker’s algorithm is run by the operating system whenever a process requests resources. The algorithm avoids deadlock by denying or postponing the request if it determines that accepting the request could put the system in an unsafe state (one where deadlock could occur). When a new process enters a system, it must declare the maximum number of instances of each resource type that may not exceed the total number of resources in the system. Also, when a process gets all its requested resources it must return them in a finite amount of time” – source Wikipedia

LIMITATION

“Like other algorithms, the Banker’s algorithm has some limitations when implemented. Specifically, it needs to know how much of each resource a process could possibly request. In most systems, this information is unavailable, making it impossible to implement the Banker’s algorithm.“ – source Wikipedia

Following Links can be referenced:

Sample Output

Enter the number of resources:4

Enter the number of processes:5

Enter  Claim Vector:8 5 9 7

Enter Allocated Resource Table:
2 0 1 1
0 1 2 1
4 0 0 3
0 2 1 0
1 0 3 0

Enter Maximum Claim table:
3 2 1 4
0 2 5 2
5 1 0 5
1 5 3 0
3 0 3 3

The Claim Vector is:    8   5   9   7
The Allocated Resource Table:
2   0   1   1
0   1   2   1
4   0   0   3
0   2   1   0
1   0   3   0

The  Maximum Claim Table:
3   2   1   4
0   2   5   2
5   1   0   5
1   5   3   0
3   0   3   3

Allocated resources:    7   3   7   5
Available resources:    1   2   2   2

Process3 is executing

The process is in safe state
Available vector:   5   2   2   5
Process1 is executing

The process is in safe state
Available vector:   7   2   3   6
Process2 is executing

The process is in safe state
Available vector:   7   3   5   7
Process4 is executing

The process is in safe state
Available vector:   7   5   6   7
Process5 is executing

The process is in safe state
Available vector:   8   5   9   7
23 questions
0
votes
1 answer

Reiterating a linked list (Bankers Algorithm)

I am making a simple bankers algorithm simulator. When I compare the need with the available resources it works fine for 1 loop. However I cannot get it to reiterate the linked list again. (In bankers algorithm you may only be able to run the…
user4809162
0
votes
1 answer

Need some clarification on Bankers Algorithm

just a quick query about safe/unsafe states in Dijkstra's Banker's algorithm... If one of the processes in the snapshot of the system (for example the one below) already has all of its needs fulfilled and there are not sufficient resources available…
Moonshield
  • 905
  • 8
  • 16
0
votes
1 answer

Use of Banker's Algorithm

Why we need banker's algorithm when we have locks,completion variables and semaphores.Since locks are acquired in linux in definite order,there can't be any deadlocks.So what is the use of running banker's algorithm in such situation.
0
votes
3 answers

Banker's algorithm solution for given system state

I have final test in OS Course, in the morning tomorrow, and I got stuck with an problem. Say we have 4 processes in our system: P1, P2, P3, P4, and 4 different resources: R1, R2, R3, R4. Current state of the system shown in this picture. The…
Alexander R.
  • 1,642
  • 12
  • 18
0
votes
1 answer

homework:Bankers Algorithm,read matrix txt file

Bankers algorithm: I am trying to read from txt file into 4 variables. allocation,Max matrix/ available and request vectors. i am stuck as to how to read it properly. The txt file first value is number of process and 2nd value is resources, the…
-1
votes
3 answers

Bankers algorithm for deadlock avoidance in c

i have implemented the bankers algorithm for deadlock avoidance..... but im not getting a safe sequence...... can anyone tell me what is wrong with my code.....???? kindly guide me..... program code is as follows: #include #include…
chinu
  • 147
  • 4
  • 6
  • 12
-2
votes
1 answer

Bankers Algorithm processes

Using Bankers algorithm, If a process (p1) is unable to complete by any other process p2,p3,p4 etc giving up it's resources singly, can they ALL relinquish their resources together so p1 could complete? Or is that not a thing that could be done?
bhigg890
  • 27
  • 2
-6
votes
1 answer

Bankers algorithm

I have a question about the answer to a problem on Dijkstra's Banker's Algorithm (the question is provided in the screen shot below). I thought the answer to this question should be "yes, it is possible to do it". My thinking is that once user 1 is…
1
2