0% found this document useful (0 votes)
1 views

Cs604. Assignment

Uploaded by

Xtylish Mughal
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)
1 views

Cs604. Assignment

Uploaded by

Xtylish Mughal
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/ 6

Part 1: Initial Available Resources and Need Matrix

1. Calculate the initial available resources:

Total Resources: Qazi

[7 2 WhatsApp: +923074960034

Allocation Matrix:

010

|2 0 1

3o2

CONTACT ON WHATSAPP

+923074960034

Sum of Allocated Resources for each resource type

[0+2+3 1+0+0 0+1+2]= [5 1

Available Resources:

[7-5 2-1 3-3]=2

2, Calculate the Need Matrix:


Need-Max-Allocation

Maximum Demand Matrix:

[6 1

0 2l

3]

Allocation Matrix:

[0 1 0]

201

l3 0 2

Need Matrix:

|6- 0 1-1 2-01 6 0 2]

3-2 1-0

l5 -3 0-0 2- 2l 12 0 0 Qazi

Part 2: Determine if the current system state is safe

1. Safety Algorithm:
Step 1: lnitialize Work and Finish: g180404611

Work = Available = [2

Finish - [false false false]

o Step Z: tind an index iii such that botn:

Finish[i]=false

and

Need[ijsWork

If no such i exists, go to Step 4.

Finish[i]-false

and

Need[i]sWork

If no such i exists, go to Step 4.

. Check PO:

Need[0] =[6 2] (2
. Check Pl:

Need[1] = [I 1 1]2

. Check P2:

Need[2] =2 0 0] (2

Update Work and Finish:

Work = Work + Allocation[2] = [2

2] =[5

Finish -[false false

truel

21
0] → skip PO

0] → skip PI

0] → P2 can Proceed

0]

. Check P0:

Need[0] = [6 0 219[5 2] → skip P0

Check heck 4Inaid Oazi

Nced[1] -[1 1 ]<[5 1 2]→ Pl can procccd

Update Work and Finishi 923074960034

Work - Work + Allocation[ 1] -[5 1 2] +

[2 0 1]=[7 3]

Finish = [false true true]

. Check PO:

Need[0] = [6 2]<[7 31 → P0 can proceed


Update VWork and Finish:

Work - Work + Allocation[0] -[7 3]+

0] = [7 2 3]

Finish =[true true truel

o Step 4: If Finish[i] is true for all i, then the system is in a safe state.

Conclusion:

Since all processes can complete, the system is in a safe state. The safe
sequence is:

P2 PO

You might also like