Consider the following snapshot of a system: Allocation Max Available ABCD ABCD
ID: 3699379 • Letter: C
Question
Consider the following snapshot of a system:
Allocation Max Available
ABCD ABCD ABCD
P0 2001 4212 3321
P1 3121 5252
P2 2103 2316
P3 1312 1424
P4 1432 3665
Answer the following questions using the banker’s algorithm:
a. Illustrate that the system is in a safe state by demonstrating an order in which the processes may complete.
b. If a request from process P1 arrives for (1, 1, 0, 0), can the request be granted immediately?
c. If a request from process P4 arrives for (0, 0, 2, 0), can the request be granted immediately?
Explanation / Answer
Allocation
A B C D
Max
A B C D
Need = Max-Allocation
A B C D
Available
A B C D
a.
Process P0 can execute as Need(P0) < Available
After execution , Available = Available + Allocation(P0)
Available = <3 3 2 1> + <2 0 0 1> = < 5 3 2 2>
Process P1 can execute as Need(P1) < Available
After execution , Available = Available + Allocation(P1)
Available = <5 3 2 2> + <3 1 2 1> = < 8 4 4 3>
Process P2 can execute as Need(P2) < Available
After execution , Available = Available + Allocation(P2)
Available = <8 4 4 3> + <2 1 0 3> = < 10 5 4 6>
Process P3 can execute as Need(P3) < Available
After execution , Available = Available + Allocation(P3)
Available = <10 5 4 6> + <1 3 1 2> = < 11 8 5 8>
Process P4 can execute as Need(P4) < Available
After execution , Available = Available + Allocation(P4)
Available = <11 8 5 8> + <1 4 3 2 > = < 12 12 8 10>
Thus the system is in safe state and execution order of processes is <P0,P1,P2,P3,P4>
b.If a request from process P1 arrives for (1, 1, 0, 0), the request be granted immediately because the Need < Available .
c. If a request from process P4 arrives for (0, 0, 2, 0), the request be granted immediately because the Need < Available .
Do ask if any doubt. Please upvote.
Allocation
A B C D
Max
A B C D
Need = Max-Allocation
A B C D
Available
A B C D
P0 2 0 0 1 4 2 1 2 2 2 1 1 3 3 2 1 P1 3 1 2 1 5 2 5 2 2 1 3 1 P2 2 1 0 3 2 3 1 6 0 2 1 3 P3 1 3 1 2 1 4 2 4 0 1 1 2 P4 1 4 3 2 3 6 6 5 2 2 3 3