The Gateway to Computer Science Excellence
+9 votes

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
  4. Deadlock state
in Operating System by Boss (30.9k points) | 2.8k views
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

6 Answers

+22 votes
Best answer

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)

So answer is Unsafe State.

by Loyal (9.9k points)
selected by
if there were no resource available then it would be deadlock state right ?
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.
+2 votes
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

Answer (B)
by Veteran (119k points)
which answer is correct? second one sounds more correct to me.
@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.

Please check again. C is the answer.
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)
I think option a since sequence like p3 p2 p1 may lead to deadlock in type 1 na
why not option C).....

Agreed @shivanisrivarshini  ...

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 ??



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 ???

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.
yes ur correct unsafe state
So, C is right,,
how vijay????...///process releases...all the resources..when it is completely releases..voluntreeril??

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

@Tauhin Gangwar sir ... please read again ... 

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...

@cse itz not the defination of the  deadlock & unsafe state..

I have to read it completely..i am getting confused
There does not exist any safe sequence so the system is in unsafe state. It may or may not be in dead lock state
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?
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)
0 votes
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)
0 votes
Answer is A because it can go to safe or unsafe according to sequence
by (139 points)
I think C is the right answer.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,391 answers
105,442 users