I'm reading about Banker's algorithm from here, I know that one condition to check if we can allocate available resource to a process is that check whether Work > Need, my wonder is that can we do so if Work < Need but Work + Allocation > Need.
For example, there are three resources R1, R2, R3 and we have already allocated P1
(0,0,4), it still needs (2,3,1) to finish its job. Now we have (2,3,0) resources available. Is it safe to give these resources to P1
and make sure there is no deadlock?
No, it's not safe because the system has
0
resources of type3
(last argument in (2,3,0)), whileP1
needs1
resource of this type - (2,3,1).If your process
P1
demands all the resources, the system puts such a request on a waiting list (it lacks a resource of type3
). Then, all of your other processes demand additional resources too, and so the system adds their requests to the queue.So, neither of the processes can finish and release resources because they all are waiting for other processes to complete. Since, the request from
P1
wants more than what is possible, it never completes, and so do the other requests. Hence, you have a deadlock situation.