0% found this document useful (0 votes)
9 views4 pages

Cs 604

The document outlines a calculation of initial available resources and the need matrix for a system with three processes. It determines that the system is in a safe state after checking the processes' needs against available resources, concluding with the safe sequence {P2, P1, P0}. The calculations include total resources, allocated resources, and the step-by-step checking process for safety.

Uploaded by

sevdaism789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Cs 604

The document outlines a calculation of initial available resources and the need matrix for a system with three processes. It determines that the system is in a safe state after checking the processes' needs against available resources, concluding with the safe sequence {P2, P1, P0}. The calculations include total resources, allocated resources, and the step-by-step checking process for safety.

Uploaded by

sevdaism789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Student ID: BC220416477

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

Need Matrix = (Max- Allocation)

( )
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

Step By step Checking process:


Check P0:
Need: [6 , 0 , 2]
Available: [2, 1 , 0]
Since , Need <=Available is false, P0 cannot proceed.
Check P1:
Need: [1 , 1 , 1]
Available: [2, 1 , 0]
Since , Need <=Available is false, P0 cannot proceed.
Check P2:
Need: [2 , 0 ,0 ]
Available: [2, 1 , 0]
Since , Need <=Available is true, P1 can proceed.
After P2 finishes, it releases it’s resources: [3 , 0, 2]
New available resources: [2+3, 1+0, 0+2] = [5, 1, 2]
Check P0 again:
Need: [6 , 0 , 2]
Available: [5, 1 , 2]
Since , Need <=Available is false, P0 cannot proceed.
Check P1 again:
Need: [1, 1, 1]
Available: [5, 1 , 2]
Since , Need <=Available is true, P1 can proceed.
After P1 finishes, it releases it’s resources: [2, 0, 1]
New available resources: [5+2, 1+0, 2+1] = [7, 1, 3]
Check P0 again:
Need: [6, 0, 2]
Available: [7, 1 , 3]
Since , Need <=Available is true, P0 can proceed.
After P0 finishes, it releases it’s resources: [0, 1, 0]
New available resources: [7+0, 1+1, 3+0] = [7, 2, 3]
Since, all process can finish, the system is in a safe state.
The safe sequence is:
{P2, P1, P0}

------------------------------------------------------------------------------

You might also like