Question: Consider the following snapshot of a system
0

i. What is the content of the matrix need?

ii. Is the system in safe state?

iii. If the request for P1 arrives for (1,0,2) can the request be granted immediately?

Marks: 10 M

Year: May 2015

 modified 3.4 years ago by Sagar Narkar • 1.6k written 3.5 years ago by Sayali Bagwe • 2.5k
2

 written 3.4 years ago by Sagar Narkar • 1.6k
0

Need matrix

It is calculated by subtracting Allocation Matrix from the Max matrix

To check if system is in a safe state

• The Available matrix is [3 3 2].
• A process after it has finished execution is supposed to free up all the resources it hold.
• We need to find a safety sequence such that it satisfies the criteria need Need ≤ Available.
• Since Need (P1) ≤ Available , we select P1.[Available]=[Available]+[Allocation(P1)]

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

• Need(P3) ≤ Available→Available=[ 5 3 2 ]+[ 2 1 1 ]=[7 4 3 ]
• Need(P4) ≤ Available→Available=[ 7 4 3 ]+[ 0 0 2]=[ 7 4 5]
• Need(P0) ≤ Available→Available=[ 7 4 5 ]+[0 1 0 ]=[ 7 5 5]
• Need(P2) ≤ Available→Available=[ 7 5 5 ]+[ 3 0 2 ]=[10 5 7]
• So it is in safe state and the safe sequence is <p1,p3,p4,p0,p2>

A request from process P1 arrives for (1,0,2)

• System receives a request for P1 for Req(P1)[ 1 0 2 ]
• First we check if Req(P1) is less than Need(P1) → [ 1 0 2 ]< [ 1 2 2] is true
• Now we check if Req(P1) is less than Available →[1 0 2]<[ 3 3 2 ] is true.
• So we update the values as:
• Available=Available-Request=[ 3 3 2 ]- [ 1 0 2 ]=[ 2 3 0 ]
• Allocation=allocation(P1)+Request= [ 2 0 0 ]+ [ 1 0 2 ]=[ 3 0 2 ]
• Need= Need(P1)-Request=[ 1 2 2 ]- [ 1 0 2 ]=[ 0 2 0 ]

• This is the modified table

• So it is still in safe state and the safe sequence is < P1,P3,P4,P0,P2 >