Friday, January 22, 2010

What are the conditions which can cause deadlock

There are four necessary conditions that must exist if deadlock is to occur.The conditions are as follows:

  • Mutual exclusion — only one concurrent activity can use a resource at once (that is, the resource is nonsharable or at least limited in its concurrent access); using locks as an example, mutual exclusion locks as opposed to read/write locks are more likely to cause deadlock.

  • Hold and wait — there must exist concurrent activities that are holding resources while waiting for others resources to be acquired; with locks, concurrent activities must be holding locks while waiting to acquire new locks.

  • No preemption — a resource can only be released voluntarily by a concurrent activity; the locks acquired by a concurrent activity cannot be forcibly taken away from it by another activity.

  • Circular wait — a circular chain of concurrent activities must exist such that each activity holds resources (has locked the objects) that are being requested by the next activity in the chain

No comments:

Post a Comment