in Operating System edited by
5,236 views
2 votes
2 votes

Consider a scenario where 3 processes P1, P2 and P3 are sharing  x resources of the same type. The maximum need of the three processes is 4, 8, 6. It is also known that the maximum combined need of both processes P1 and P2 at a time is 9 and they always execute only in combined manner. Then the value of  x is ___

in Operating System edited by
by
5.2k views

19 Comments

What is x here?
1
1
according to wordings of qsn, x seems to be minimum resources required to avoid deadlock.

it should be, $x>=13$
0
0
x = resources I think.

Then answer should be 13.

7+5+1 = 13.

7 for P1 and P2. 5 for P3 and 1 additional resource.
0
0
Okay..then it's 13 ..
0
0
should be 14 ? p1 and p2 are always together. they together need 9 and execute together. and p3 needs 6. so 8+5+1 = 14 for deadlock-free execution?
0
0
Yes..I am actually confused between 13 and 14..

But is there any mistake in this procedure:-

Since P1 and P2 require 9 resources together at max. So let P1 requests y resources and P2 requests (9-y) resources and P3 requests 6 resources as given.

So they would be allocated 1 less than their max demand so P1 gets (y-1), P2 gets (9-y-1)=(8-y) and P3 gets 5.

So currently available resources should be at least 1 to avoid deadlock.

=> total resources -(already allocated)>=1

x-{(y-1)+(8-y)+5}>=1

x-{12}>=1

x>=13

Min(x) =13..
0
0
so what if P1 executes and then free its resources and then P3 executes next? it is said in question that P1 and P2 should execute together. either p1p2 or p2p1. so only one among p1 or  p2 should be waiting for the extra 1 resource,isn't it ?
0
0
this is what i meant.

1. P1 has already got its need but is waiting for p2 to get the 1 resource it is short of.

2. P2 gets the resource and executes in order P1 followed by P2

3. P3 gets the freed resource from P2 and starts execution.

i'm not sure if this is the way question is interpreted.
0
0
Ya..you seem to be correct..

But tell me this.. if 5 resources were already allocated to P3 and 8 resources to combined P1 and P2, then P2 having max demand of 8 resources(given) would take up all those 8 and could execute alone itself..then there won't be the deadlock case arising. Is this right?
0
0
You said that if P1 already got it's needs satisfied and P2 waits for the '1' resource it is short of? But P1 can max take 4 resources so P2 has to wait for 5 resources not just 1 .. right?
0
0

@MiNiPanda

U mean, P1 was not being allocated any resources initially and its need is 4(max need) and P2 need 5 (so total need(p1+p2)=9). and we allocate 8 resources to them to find out the minimum case.  if P1 takes 4/8 and P2 takes rest 4/8, then P1 and P2 combined is in short of 1 resource only, isn't it? 

1
1
I think we can assume P1 and P2 together as a single process with max=12 and need=9. that way we can make sure they both always execute together.
1
1
edited by
Yes..I mean if we consider P1 and P2 as a single entity and give them 8 resources then P2 might take up all those because it needs 8 resources for itself(max need of P2 is 8 given) and then there won't be any  any wait but only hold for P2 i.e. hold and wait condition is not satisfied so no deadlock. But we have to create a situation of deadlock in such type of problems..

By single entity I meant allocating resources to P1 and P2 together and they will decide within themselves about the division or the share they each take.

This was my understanding..I am not sure though..
0
0
hold and wait is when we wait for a resource held by another process.. here we are waiting for another process.. is this hold and wait?
0
0

joshi_nitish Sir and Ashwin Kulkarni please help with this.. my logic does not seem to be that convincing to myself only.. 

0
0
edited by
@minipanda see,

We can make pairs for P1 P2,

(1,8)(2,7)(3,6)(4,5)

At any moment maximum req for both the process is 8.

Hence we can give 7 to them and 1 will be backup resource and same logic with R3. we can give 5 to it and already we have 1 backup resource for completion

Hence total will be 7+5+1 = 13
0
0

You mean make pairs for P1 and P2 ? i don't get it..how 8 is the max. requirement at any time.. the pairs show that 9 is the max need...

0
0
ans is 21
1
1
(9-1)+(6-1)+1=14(=x). x+7=14+7=21
2
2

1 Answer

0 votes
0 votes

P1 and P2 both need 9 units of resource at the same time and P3 needs 6 resource, so the minimum value of x to avoid deadlock is-->

x= (9-1) + 6 = 14   Why?--> see this https://gateoverflow.in/19379/what-logic-calculating-minimum-resources-remove-deadlock

now x+7 =21

ANS= 21

by

Related questions