No Deadlock

Thread Starter

zulfi100

Joined Jun 7, 2012
656
Hi,
Can somebody plz guide me with the following question:

An OS contains 3 user processes each requiring 2 units of resource R. What is the minimum number of units of R such that no Deadlock will ever arise?
Zulfi.
 

WBahn

Joined Mar 31, 2012
29,976
Describe the largest number of resource units that could be in use and still have deadlock. You only need one more than that.

Now consider that if ANY unit has two units, then it is not blocked.
 

Thread Starter

zulfi100

Joined Jun 7, 2012
656
Hi,
Thanks for your comments. I dont know how the resources are allocated. If we have only one resource, no process can run, this may be the deadlock case. If we have 2 resources and one process can run while other two can wait. This may not result in deadlock? Kindly guide me.

Zulfi.
 

MrChips

Joined Oct 2, 2009
30,706
I'm not an expert on this but just working through the logic intuitively.
Suppose we define a deadlock as when a user requires 1 more unit and no one releases a unit.
Hence there would be a deadlock if all 3 users have tied up 1 resource each and are waiting for 1 more available resource.
So by this logic you would need 4 units of resources.
 

WBahn

Joined Mar 31, 2012
29,976
A key point to understand is that the point of avoiding deadlock isn't in determining what is required in order to be sure that it is possible that deadlock might not happen, but rather to determine what is required in order to guarantee that it will not happen.

MrChips hit it right on the nose. That's the correct logic and the correct answer.

As long as one user is guaranteed to be able to get the resources they need to run, you can't have deadlock. So the minimum number of resources you need, short of having better allocation strategies, is when all of the resources have almost what they would need and then one more to guarantee that one of them will get the last thing they need.
 
Thread starter Similar threads Forum Replies Date
Z Homework Help 2
vaidhya Microcontrollers 2
Similar threads
Deadlock
Creating deadlock
Top