You may assume a static number of processes 5 and a static n
You may assume a static number of processes (5) and a static number of resources (4).
Name: \"input4.txt\"
Line 1: Available resources
Line 2 to line n+1: Where n is the number of processes. The resources the processes have currently (the allocation) and the resources they need (the max)
Line n+2: The available resources
Line n+3: a blank line
Line n+4 and onward: A process request, such as in 7.3 part c. The process making the request, followed by the amount of each resource they want. You should continually process these lines until there are none left. Output whether or not the request can be granted. Do not allow these requests to impact the system, they are purely theoretical. Answer CAN the request be granted, do not actually grant the request.
It should look something like this:
1 5 2 0
0 0 1 2 0 0 1 2
1 0 0 0 1 7 5 0
1 3 5 4 2 3 5 6
0 6 3 2 0 6 5 2
0 0 1 4 0 6 5 6
0 1 5 2 0
1 4 5 2 0
Consider the following snapshot of a system: Allocation Max Available A BCD A BCD A BCD Po 2001 4212 3 32 1 Ph 3121 5252 P2 2103 2316 13 12 Pa 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,00, can the request be granted immediately? c. If a request from process Pa arrives for (0,0, 2,0), can the request be granted immediately?Solution
Banker\'s Algorithm :-
5 processes and 4 resource type A(with 13), B(with 12), C(with 8) and D(with 10 instance).
content of matrix need---->
a) Yes, system is in safe state. <P0, P3, P1, P2, P4> is a safe sequence.
b)Yes, if a request from process P1 arrives for (1,1,0,0) then the request be granted immediately. Because available resource is (3,3,2,1) in starting.
c)Yes, if a request from process P4 arrives for (0,0,2,0) then the request be granted immediately. Because available resource is (3,3,2,1) in starting.
| Allocation | Max | Need | Available | |
| ABCD | ABCD | ABCD | ABCD | |
| P0 | 2001 | 4212 | 2211 | 3321 |
| P1 | 3121 | 5252 | 2131 | |
| P2 | 2103 | 2316 | 0213 | |
| P3 | 1312 | 1424 | 0112 | |
| P4 | 1432 | 3665 | 2233 |

