Homework - 5 Version 0 |
|
👤 Author: by 244045932qqcom 2019-10-30 11:01:13 last modified by 244045932qqcom |
Banker's Algorithm:
When a client want to borrow cash from a bank, the banker will first ensure that cash remained in the vault after this transaction plus possible repayment from other clients is enough for other clients. If this condition is not satisfied, this transaction will be denied and the client will be asked to wait for enough cash.
In computers, the system is like a bank and cash is resource and clients are processes. The state of no enough resources for allocation is called unsafe.
Example:
Assume there are 2 different resources r1 and r2.
Process Allocated Need Available
. r1 r2 r1 r2 r1 r2
p1 1 0 2 4 6 9
p2 3 1 5 1
p3 2 0 0 8
In this case, the request of p3 for 9(r2) cannot be granted. Because the remaining r2 plus allocated r2 is 2 which is less than the need of p1.