describe your understadings about Banker's Algorithm, and give your own demo example.
Banker algorithm, as its name implies, is an algorithm that simulates the lending business of a bank. The operating system is equivalent to a banker, and the process is the customer.Can the operating system respond to a process's resource request by maintaining a normal resource turnover until it returns the allocated resource?A normal turnaround is that the system has resources available to meet the needs of multiple processes.That is, the system is in a safe state.
example:
Process: Alloccation Need Available
p0: 0 0 3 2 0 0 1 2 1 6 2 2
p0: 1 0 0 0 1 7 5 0
p0: 1 3 5 4 2 3 5 6
p0: 0 3 3 2 0 6 5 2
p0: 0 0 1 4 0 6 5 6
question:
Work Need Allocation Work+Allocation Finish
P0 1,6,2,2 0,0,1,2 0,0,3,2 1,6,5,4 T
P3 1,6,5,4 0,6,5,2 0,3,3,2 1,9,8,6 T
P1 1,9,8,6 1,7,5,0 1,0,0,0 2,9,8,6 T
P2 2,9,8,6 2,3,5,6 1,3,5,4 3,12,13,10 T
P4 3,12,13,10 0,6,5,6 0,0,1,4 3,12,14,14 T
There is safety sequence {p0->p3->p1->p2->p4}, which is safe