Assume we have 5 of some resource, and process A needs a max of 3 of them, and process B also needs a max of 3 of them. Let’s assume that process B can’t finish until A finishes.
**
tldr; B is dependent on A to finish, but the algorithm seems to assume that B can always finish no problem once it obtains its max number of resources.
But I keep reading that there can be no deadlock as long as you keep running the Banker’s algorithm.
So what’s going on?**
More in-depth description:***
Now B requests 3 of the resource. The algo should give them, because it assumes that B has taken its maximun number of resources and worst case can just be left to run until it’s done and releases the resources.
Now A requests 3 recources, the algo doesn’t give them (because there are only 2 left).
But what if B cannot complete, until it obtains some sort of result from A? Let’s say a signal.
It appears to be a deadlock: A is waiting for B to finish to get resources and be able to compute and send a signal / result over to B. And B is waiting for A to send a signal / result, so that B can finish and release the resources.
NOW had the algo given A the 3 resources first, A could have put the signal in its buffer (lets say its a pipe) and finished, then B couldve run with 3 resources, collected the buffer and also finished.
2