2.8k views

Consider the following process and resource requirement of each process.

Predict the state of this system, assuming that there are a total of $5$ instances of resource type $1$ and $4$ instances of resource type $2$.

1. Can go to safe or unsafe state based on sequence
2. Safe state
3. Unsafe state
| 2.8k views
+2
when they gives u total instance  of resources like here typ1 and type 2 ur aim is to compute available  resources of both type 1 and type then u apply banker algorithm on it then u get safe or unsafe state . and remember one thing if u got avaliable  resources of type1 and type2 is (0,0) thats means deadlock is occured

Total no of Type 1 resources = 5

Total no. of Type 2 resources = 4

Type 1 allocated = 1+1+2=4

Type 2 allocated = 1+1+1=3

Type 1 available = Total -avl = 5-4 = 1

Type 2 available = Total - avl = 4-3=1

Now this ( 1,1)  cant handle any of one further needs of any process as the need vector (MAX - USED) for the processes are

1. (1,2)
2. (2,1)
3. (2,3)

by Loyal (9.9k points)
selected
+1
if there were no resource available then it would be deadlock state right ?
0
Deadlock will occur when the resource has actually been allotted. Here the resources are not allotted, but we can see that there is no way in which we can satisfy the requirement. Hence unsafe state.
Type1:  Need 1 2 2

U have remain 5-(1+1+2)=1 instance

P1 take that instance and then released the resources

then P2 executes as it requires 2 more instances , then P3 executes

So, Type1 in safe state

Now Type 2 need 2 1 3 instances

Type2 remain 1 instances in hand

P2 takes that instance and executed

then P2 releases its resourses

P2 releases 2 instances

P1 requires 2 instances , it takes and executed

then P3 also executes

So, both are in safe state

by Veteran (119k points)
0
which answer is correct? second one sounds more correct to me.
+5
@shreshta : p1 complete execution when it gets 1 instance of type and 2 instance of type 2 . getting 1 intance of type1 not sufficient to complete execution of p1.

+1
p1 can not execute without having proper no of type2 resource hence it can not be safe state
+1 vote
answer is (b) , I think in every sequence operating system has enough resources to allocate to processes.
by Loyal (8.5k points)
+1
I think option a since sequence like p3 p2 p1 may lead to deadlock in type 1 na
+1
why not option C).....
0

Agreed @  ...

But I have one doubt here... here every process needs two types of resource. My question is after taking all max need of type 1 resource can it release type 1 resource and at the same time need of resource type 2 is not fulfilled ??

For example if we try to schedule like - p1, p2 ,p3 ... is it going to lead us in deadlock or not ??

0

@vijaycs07

If we consider in this way

 Type1 (req) Type2(req) P1 1 2 P2 2 1 P3 2 3

type1 we have only 1 resource , type 2 we have only 1 resource

with that we can finish P1 use of type1 P2 use of type 2 but if processes dnt release resouces till its completion then non will be finished and leads to deadlock ???

+1
You got it right @shivani ... so what do you say ... can we get any safe state  ?? If yes then it means process has to release resource in the middle of completion ??

Acc. to me ... its not safe ... so ans should be C.
+2
yes ur correct unsafe state
+1
So, C is right,,
0
how vijay????...///process releases...all the resources..when it is completely done....it releases..voluntreeril??

how u take 1 one type resources and release it...& then take type2...
0
unsafe is the right answer...whosover solved it...keep it up..
0

0
plz don't call me sir...////vijay u r right....i had a bit confusion between unsafe and deadlock...but i verified it...unsafe is the accurate answer...
0
need=max-used
0

0
I have to read it completely..i am getting confused
0
There does not exist any safe sequence so the system is in unsafe state. It may or may not be in dead lock state
0
When it could have been in dead lock state?? When all available resources become 0 or what? in this case we know that later available resources are going to be 0. So why can't we say it as dead lock?
0
Ohh it may be the case that these processes doesn't need to acquire all maximum resources which they are allowed to acquire. In such case they will complete their execution and release the resources. ( I was assuming they have to get all max number of resources in order to complete execution)

So the system will called to be in a deadlock state if two process (p1 and p2) are requesting resources such that p1 requesting resource by p2 and p2 requesting resource held by p1. As no such requests are available, the system is only in unsafe state not deadlock.
+1 vote

both are in the safe state

by Active (4.9k points)
There does not exist any safe sequence so the system is in unsafe state. It may or may not be in dead lock state
by (195 points)
Answer is A because it can go to safe or unsafe according to sequence
by (139 points)
0
I think C is the right answer.