Skip to content
breathTake edited this page Aug 19, 2023 · 3 revisions

Bankier Algorithm:

Step 1: Initialization

The algorithm starts with the current available resources and the maximum demand of each process.

Step 2: Request for Resources

When a process requests resources, the system checks if the requested resources are available. If the requested resources are less than or equal to the available resources, the system temporarily grants the resources to the process for testing purposes.

Step 3: Safety Check

The system performs a safety check to determine if allocating the requested resources would result in a safe state. It simulates the allocation by marking the requested resources as allocated for that process and reducing the available resources accordingly.

Step 4: Test for Safe State

The algorithm checks if the system remains in a safe state after allocating the requested resources. It uses a loop to iteratively find a process that can be completed with the available resources. If such a process is found, its allocated resources are released and added back to the available resources. The loop continues until no more processes can be completed or all processes are completed.

Step 5: Decide to Grant or Delay

If the system can reach a safe state after allocating the requested resources, the resources are actually granted to the process. If not, the requested resources are not granted, and the process is kept waiting.

Step 6: Release Resources

When the process finishes using the allocated resources, it releases them. The released resources are added back to the available resources.

Step 7: Repeat

The process repeats as new resource requests and releases occur.

Clone this wiki locally