Homework5 Version 0 |
|
👤 Author: by 59739640qqcom 2019-10-17 00:58:01 |
describe your understandings about Banker's Algorithm, and give your own demo example.
What's banker's algorithm?
first some attribute is defined in the algorithm : Available, Max, Allocation and Need .
suppose here are three types of resources in the memory and some processes are waiting for some of those resources . Without enough resources , we can't finish those processes.
so, at the very beginning, the memory will allocate some of its resources to those processes but some of those resources will remained available .overall processes can take those available resources if their allocated can up to the max size.When the allocated resources upper to the Max then the process is able to be finished .After a process finished, its allocated resources will immediately
return to memory and those resources will increase the available resources in memory so that the memory can move on to next process.
Here is my demo:
A B C
volume dose: 11 7 9
P0 need(MAX): 2 1 0
p1 need(MAX): 3 6 6
P3 need(MAX): 9 5 4
P4 need(MAX): 6 2 5
po allocated: 1 0 0
p1 allocated: 3 4 1
p2 allocated: 2 1 0
p3 allocated: 0 1 4
p4 allocated: 3 1 1Available: 2 0 3
So the available scheme is : P0-P1-P4-P3