FOUR NECESSARY CONDITIONS REQUIRED TO ALLOW DEADLOCK

To have the potential for deadlock between two or more threads and the set of resources that are required by each, four conditions must be met. In a paper titled, "Sequencing tasks in multiprocess systems to avoid deadlocks" (in Conference Record of 1970 Eleventh Annual Symposium on Switching and Automata Theory), E. G. Coffman, Jr. and A. Shoshani first enumerated these four conditions as follows:

  • Mutual exclusion condition
    Individual resources are either available or they are held by no more than one thread at a time.
  • Hold and wait condition
    Threads that are already holding some resources may attempt to hold new resources.
  • No preemption condition
    Once a thread is holding a resource, that resource can only be removed when the holding thread voluntarily releases the resource.
  • Circular wait condition
    A circular chain of threads requesting resources that are held by the next thread in the chain can exist.

To prevent the possibility of deadlock from occurring, one of these conditions must not be allowed to exist. There are many different ways to prevent one or more of these conditions. A text on operating systems theory should have some discussion about deadlock and how you can prevent it.

posted on 2010-09-12 17:05  胡是  阅读(228)  评论(0编辑  收藏  举报

导航