0% found this document useful (0 votes)
189 views3 pages

The Banker

The Banker's Algorithm is a resource allocation and deadlock avoidance algorithm that simulates allocating all resources to determine if the system will enter an unsafe state where deadlock could occur. It works by keeping track of resources that are available, allocated, and the maximum requested by each process. When a new request is made, the algorithm determines if granting it would leave the system in a safe state where all processes could terminate, and denies the request if it would make the system unsafe. This avoids potential deadlocks by not allocating resources in a way that prevents all processes from completing.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
189 views3 pages

The Banker

The Banker's Algorithm is a resource allocation and deadlock avoidance algorithm that simulates allocating all resources to determine if the system will enter an unsafe state where deadlock could occur. It works by keeping track of resources that are available, allocated, and the maximum requested by each process. When a new request is made, the algorithm determines if granting it would leave the system in a safe state where all processes could terminate, and denies the request if it would make the system unsafe. This avoids potential deadlocks by not allocating resources in a way that prevents all processes from completing.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CHAPTER 1

BANKER’S ALGORITHM

1.1 Introduction

It is a resource allocation & deadlock avoidance algorithm developed by Edsger Dijkstra that
tests for safety by simulating the allocation of pre-determined maximum possible amounts of all
resources, and then makes a "safe-state" check to test for possible deadlock conditions for all
other pending activities, before deciding whether allocation should be allowed to continue.

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.

The Banker's Algorithm derives its name from the fact that this algorithm could be used in a
banking system to ensure that the bank does not run out of resources, because the bank would
never allocate its money in such a way that it can no longer satisfy the needs of all its customers.
By using the Banker's algorithm, the bank ensures that when customers request money the bank
never leaves a safe state. If the customer's request does not cause the bank to leave a safe state,
the cash will be allocated, otherwise the customer must wait until some other customer deposits
enough.

1.2 Features of Banker’s Algorithm


 Multiple instances.
 Each process must claim maximum use in advance.
 When a process requests a resource it may have to wait.
 When a process gets all its resources it must return them in a finite amount of time.
1.3 Resources allocation criteria

For the Banker's algorithm to work, it needs to know three things:

 How much of each resource each process could possibly request.


 How much of each resource each process is currently holding.
 How much of each resource the system currently has available.

Resources may be allocated to a process only if it satisfies the following conditions:

 request ≤ max, else set error condition as process has crossed maximum claim made
by it.
 request ≤ available, else process waits until resources are available.

1.4 Unsafe States

A state is considered safe if it is possible for all processes to finish executing (terminate). Since
the system cannot know when a process will terminate, or how many resources it will have
requested by then, the system assumes that all processes will eventually attempt to acquire their
stated maximum resources and terminate soon afterward. This is a reasonable assumption in
most cases since the system is not particularly concerned with how long each process runs (at
least not from a deadlock avoidance perspective). Also, if a process terminates without acquiring
its maximum resources, it only makes it easier on the system.

Given that assumption, the algorithm determines if a state is safe by trying to find a hypothetical
set of requests by the processes that would allow each to acquire its maximum resources and then
terminate (returning its resources to the system). Any state where no such set exists is an unsafe
state.
1.5 Requests

When the system receives a request for resources, it runs the Banker's algorithm to determine if it
is safe to grant the request. The algorithm is fairly straight forward once the distinction between
safe and unsafe states is understood.

 Can the request be granted?


If not, the request is impossible and must either be denied or put on a waiting list
 Assume that the request is granted
 Is the new state safe?
If so grant the request
If not, either deny the request or put it on a waiting list

Whether the system denies or postpones an impossible or unsafe request is a decision specific to
the operating system.

1.6 Limitations

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. Also, it is unrealistic to assume that the number of processes is static since in most
systems the number of processes varies dynamically. Moreover, the requirement that a process
will eventually release all its resources (when the process terminates) is sufficient for the
correctness of the algorithm, however it is not sufficient for a practical system. Waiting for hours
(or even days) for resources to be released is usually not acceptable.

You might also like