2
$\begingroup$

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:

enter image description here

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Raphael Apr 10 '16 at 17:31
  • $\begingroup$ 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. $\endgroup$ – vzn Apr 10 '16 at 22:11
1
$\begingroup$

The maximum resources are an estimate by the process of what they might need, the currently allocated is what the process holds at the moment. The idea is that processes request more resources as they need them (and at those points you run the algorithm to see if it could lead to deadlock to grant the resources asked for, by seeing if there is a process that could finish and release all it holds if it goes on to ask for it's maximum announced request, releases what it holds, and so on). If a process releases resources, that clearly can't lead to a deadlock, thus no special handling (except for recording what is free now) is needed.

Think of you e.g. building a box out of wood, and the tools needed. You'll need a saw, a drill, a screwdriver, among other tools. You'd announce that, but you won't require all together, while you are busy with the saw somebody else could use the drill and screwdriver, so it doesn't make sense to ask for all at the start, or keep all until finished.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.