in Operating System
7,620 views
9 votes
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
7.6k views

1 comment

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

7 Answers

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

selected by

2 Comments

if there were no resource available then it would be deadlock state right ?
1
1
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.
1
1
3 votes
3 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)

3 Comments

which answer is correct? second one sounds more correct to me.
1
1
@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.
5
5
p1 can not execute without having proper no of type2 resource hence it can not be safe state
1
1
1 vote
1 vote
answer is (b) , I think in every sequence operating system has enough resources to allocate to processes.
by

4 Comments

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
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?
1
1
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.
0
0
1 vote
1 vote

both are in the safe state 

Answer:

Related questions