# Confusion in Banker's Algorithm: How resources are allocated?

I have seen examples about Banker's Algorithm from this Wikipedia link, this book and many other places. In all these examples some processes are allocated resources less than their Max Need.

For example, consider the state of system as shown in below given image taken from Wikipedia link:

Here you can see that the process P1's Max Need is 3 3 2 2 and the total available resources are 6 5 7 6. But the system allocates 1 2 2 1 resources to P1. Although it could allocate all the requested resources to P1 and P1 would have completed.

So my questions are:

• Why does the system allocate partial / incomplete resources even when it has the resources available
• If the allocation of partial / incomplete resources is allowed, then why does the system / algorithm enforce that the number of requested / needed resources should be less than the available resources (at the time of request)?. The system could allocate some resources (available at the time of request) to process(es) and the remaining would have been assigned when released by other processes.

OR

The process has to tell the number of resource types (and their instances) in advance, but does not need to be assigned all resources at a time; rather it is assigned resources when actually needed?

Please correct me if I am wrong.

• We expect references to fulfill the minimal scholarly requirements and be as robust over time as possible. Please take some time to improve your post in this regard. We have collected some advice here. – Raphael Apr 10 '16 at 17:31
• a major design criteria of this algorithm seems to be to (provably) avoid deadlocks (due to lack of resources), and therefore the allocation logic must know the most resources that will ever be requested to fulfill the proof. ofc there are zillions of algorithms for resource allocation and others may be more apropriate for some situations. other algorithms may better mesh with some of the different scenarios youre asking about. if you look into the proof of how the algorithm avoids deadlock you will likely find the conditions as requirements of the proof & can understand better the design. – vzn Apr 10 '16 at 22:11