An operating system contains 3 resource classes. The number of resource units in these classes is 7, 7 and 10. The current resource allocation state is shown below:
Processes
|
Allocated resources
|
Maximum requirements
|
R1
|
R2
|
R3
|
R1
|
R2
|
R3
|
P1
|
2
|
2
|
3
|
3
|
6
|
8
|
P2
|
2
|
0
|
3
|
4
|
3
|
3
|
P3
|
1
|
2
|
4
|
3
|
4
|
4
|
(i) Is the current allocation state safe?
(ii) Can the request made by process P1 (1, 1, 0) be granted?
(i) In the specified question,
Available matrix for resources [R1 R2 R3] = No of resource unit - Total Allocation
= [7 7 10]-[5 4 10] = [2 3 0]
Need matrix is identified as (Max - Allocation),
Processes
|
Need of resources
|
R1
|
R2
|
R3
|
P1
|
1
|
4
|
5
|
P2
|
2
|
3
|
0
|
P3
|
2
|
2
|
0
|
By using Safety Algorithm, we find sequence:
Processes
|
Available resources
after satisfying need
|
R1
|
R2
|
R3
|
2
|
3
|
0
|
P2
|
4
|
3
|
3
|
P3
|
5
|
5
|
7
|
P1
|
7
|
7
|
10
|
The sequence < P2, P3, and P1 > satisfies the safety criteria. Therefore current allocation state is safe.
(ii) Request made through process P1, Request (P1) = [1 1 0] Here, Request (P1) < Need (P1) < Available
That is [1 1 0]< [1 4 5] < [2 3 0]
Pretending such request can be fulfilled, we find new state:
Processes
|
Allocation
|
Need
|
Available
|
R1
|
R2
|
R3
|
R1
|
R2
|
R3
|
R1
|
R2
|
R3
|
P1
|
3
|
3
|
3
|
0
|
3
|
5
|
1
|
2
|
0
|
P2
|
2
|
0
|
3
|
2
|
3
|
0
|
P3
|
1
|
2
|
4
|
2
|
2
|
0
|
Because Need > Available for all process, no need can be fulfilled therefore allocation is not thread safe that is request made through Process P1 can't be granted.