0% found this document useful (0 votes)
2 views2 pages

Bankers Algorithm Notes

The Banker's Algorithm is a deadlock avoidance method used in operating systems to determine if resource requests can be granted while keeping the system in a safe state. It involves processes declaring their maximum resource needs and checking if granting a request maintains safety through a series of calculations. While it effectively prevents deadlock and ensures predictable behavior, it requires prior knowledge of resource needs and may be inefficient for large or dynamic systems.

Uploaded by

Andrew Tate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Bankers Algorithm Notes

The Banker's Algorithm is a deadlock avoidance method used in operating systems to determine if resource requests can be granted while keeping the system in a safe state. It involves processes declaring their maximum resource needs and checking if granting a request maintains safety through a series of calculations. While it effectively prevents deadlock and ensures predictable behavior, it requires prior knowledge of resource needs and may be inefficient for large or dynamic systems.

Uploaded by

Andrew Tate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Banker's Algorithm (Deadlock Avoidance)

Definition:

The Banker's Algorithm is a deadlock avoidance algorithm used in operating systems.

It helps the system decide whether or not to grant resource requests by checking if

doing so keeps the system in a safe state.

The algorithm is named after a banker who gives loans only if he is sure he can satisfy

all customers' maximum future demands without running out of money.

Key Terms:

- Maximum Need: Maximum number of resources a process may need.

- Allocation: Current number of resources allocated to the process.

- Need: Remaining resources the process may still request (Need = Max - Allocation).

- Available: Total free resources currently available in the system.

How It Works (Step-by-step):

1. Each process declares its maximum need of each resource type.

2. When a process requests resources:

- The system pretends to allocate them.

- It checks if the system remains in a safe state.

- A safe state means there's at least one sequence in which all processes can finish.

3. If the system is still safe -> grant the resources.

4. If the system is not safe -> deny the request and make the process wait.

Safety Check Algorithm:


1. Create a Work vector equal to Available, and a Finish array (initially false for all processes).

2. Find a process P such that:

- Finish[P] == false, and

- Need[P] <= Work

3. If found:

- Work = Work + Allocation[P]

- Finish[P] = true

- Repeat Step 2.

4. If all Finish[i] = true, the system is in a safe state.

Advantages of Banker's Algorithm:

- Prevents Deadlock: It avoids unsafe allocations that could lead to deadlock.

- Safe System State: Always keeps the system in a safe condition.

- Predictable Behavior: Allocations are done only after confirming safety.

- Works Well with Fixed Resource Requests: Good when process needs are known in advance.

Limitations (optional):

- Requires all processes to declare max resources in advance.

- Can be slow for large systems (many calculations).

- Not practical for systems where resources change frequently.

You might also like