in Operating System
5,650 views
11 votes
11 votes

A total of 9 units of a resource type available, and given the safe state shown below, which of the following sequence will be a safe state?

Process Used Max
$P_1$ 2 7
$P_2$ 1 6
$P_3$ 2 5
$P_4$ 1 4
  1. $\langle P_4, P_1, P_3, P_2\rangle$
  2. $\langle P_4, P_2, P_1, P_3\rangle $
  3. $\langle P_4, P_2, P_3, P_1\rangle $
  4. $\langle P_3, P_1, P_2, P_4 \rangle$
in Operating System
5.7k views

2 Answers

13 votes
13 votes
Best answer
Process Used Max Need
P1 2 7 5
P2 1 6 5
P3 2 5 3
P4 1 4 3

We have total 9 resources and out of 9, 6 are already allocated to the processes. Now we are left with 3 resource which can fulfill the need of process P3 and P4. Now if we check options A, B and C where first P4 is being served then after completion of P4 we will have total 3 + 1 = 4 resources but now we can't fulfill the need of either P1 or P2, because each needs 5 resource so option A, B and C can not be correct ans. Similarly we can check for option D where after P3 we can fulfill any combination. So Ans- D. <P3,P1,P2,P4><P3,P1,P2,P4><P3,P1,P2,P4>

selected by

4 Comments

You forget to mention how we decided among Process p3 and p4 when they have equal NEED of resource. Note: When Arrival time is not specified expliclity then consider process naming sequence. P1, P2, P3 and P4
0
0
^ please read the solution again .. I think, I have mentioned that point ...actually sometimes reverse engineering helps in getting ans quickly. ..so I used options filtering ...
1
1

@vijaycs  other than given options is Sequence <P4,P3,P2,P1> could be the also??

0
0
That is a really good solution.

Thanks.
0
0
5 votes
5 votes

According to me answer should be

⟨P3,P1,P2,P4⟩

Available resourses A=3

By this we can only fulfill the future need of the P3

Now new availbility Anew=3+2=5,

By Anew we can fill the need of P1 or P2,Suppose we fill need of P1,then Anew=5+2=7

Anew=7,Now for P2;

Anew=7+1=8

Finally with P4;

Anew=8+1=9

So our system is safe and safe sequence is P3---->P1------->P2------>P4

1 comment

Perfect
0
0
Answer:

Related questions