Cs 604
Cs 604
CS604
Assignment no: 02
Part 1:
1. Calculate the initial available resource.
Answer:
Total Resources:
A: 7
B: 2
C: 3
Allocation Matrix:
A BC
( )
0 1 0
2 0 1
3 0 2
To calculate the available resources, we first sum up the resources allocated to all processes:
Allocated resources:
A: 0+2+3 = 5
B: 1+0+0 = 1
C: 0+1+2 = 3
Then, subtract these from the total resources:
Initial Available resources:
A: 7-5 = 2
B: 2-1 = 1
C: 3-3 = 0
2. Calculate the Need matrix.
Maximum Demand (Max) Matrix:
A BC
( )
6 1 2
3 1 2
5 0 2
Allocation Matrix:
A BC
( )
0 1 0
2 0 1
3 0 2
( )
6−0 1−1 2−0
= 3−2 1−0 2−1
5−3 0−0 2−2
( )
6 0 2
= 1 1 1
2 0 0
Part 2:
Determine if the current system state is safe
Initial Available resources:
(2 1 0 ¿
Need Matrix:
( )
6 0 2
1 1 1
2 0 0
Allocation Matrix:
( )
0 1 0
2 0 1
3 0 2
------------------------------------------------------------------------------