0% found this document useful (0 votes)
12 views2 pages

Bankarsalgoexample

The document outlines a resource allocation scenario with processes P0 to P4 and their respective allocation and maximum resource needs. It calculates the need matrix and applies the safety algorithm to determine if the system is in a safe state, concluding with a safe sequence of process execution. Additionally, it discusses a resource request from process P1 and evaluates whether it can be granted immediately.

Uploaded by

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

Bankarsalgoexample

The document outlines a resource allocation scenario with processes P0 to P4 and their respective allocation and maximum resource needs. It calculates the need matrix and applies the safety algorithm to determine if the system is in a safe state, concluding with a safe sequence of process execution. Additionally, it discusses a resource request from process P1 and evaluates whether it can be granted immediately.

Uploaded by

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

Allocation Max Available

ABC ABC ABC


P0 010 753 332
P1 200 322
P2 302 902
P3 211 222
P4 002 433
a) What is content of matrix need:
We know that,
Need(I,j)=max(i,j)-allocation(i,j)
ABC
P0 743
P1 122
P2 600
P3 011
P4 431
b) Is system is safe… safety algorithm
Let work=Available (3,3,2)
Now for p0
Finish(p0)==false,…… true
Need(p0) <=work…?
Po(7, 4, 3)<=(3,3,2)……false
Po has to wait.

For p1
Finish(p1)==false…..TRUE
Need(P1) = (1,2,2)
NEED(P1)<=WORK
(1,2,2)<=(3,3,2)…..true
Work=work+allocation(p1)
Work=(3,3,2)+(2,0,0)
=(5,3,2)
Finish(p1)=true………………………………………1

for p2
need=(6,0,0)
(6,0,0)<=(5,3,2)……………………………..false
Process p2 has to wait
For p3
Need=(0,1,1)
(0,1,1)<=(5,3,2)…..true
Work=(5,3,2)+(2,1,1)
=(7,4,3)
Finish(p3)=true……………………………………..2
For p4
Need=(4,3,1)
(4,3,1)<=(7,4,3)….true
Work=(7,4,3)+(0,0,2)
=(7,4,5)
Finish(p4)=true…………………………………………3

First cycle is over. Now again for second cycle,


For p0
Need=(7,4,3)<=(7,4,5)……true
Work=(7,4,5)+(0,1,0)
=(7,5,5)
Finish(p0)=true……………………………..4

For p2,
Need=(6,0,0)<=(7,5,5)
Work=(7,5,5)+(3,0,2)
=(10, 5, 7)
Finish(p2)=true…………………………………….5

Safe sequence is …
<p1, p3, p4, p0, p2>

3) request for process p1 arrives for (3 3 0)


Solve this using resource request algorithm and give your answer as
-Request can be/can not be granted immediately.

You might also like