Microsoft Store
 

Deadlock


 

A deadlock is a situation wherein two or more competing actions are waiting for the other to finish, so neither ever does. It is often seen in a paradox, like the chicken or the egg.

Deadlock prevention

Deadlocks can be prevented by ensuring that one of the following four conditions does not occur:

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

  • Removing the mutual exclusion condition means that no one process may have exclusive access to a resource. This proves impossible for resources that cannot be spooled, and even with spooled resources deadlock could still occur.
  • The conditions may be removed by requiring processes to request all the resources they will need before starting up; this advance knowledge is again impossible in many cases. Another way is to require processes to release all their resources before requesting all the resources they will need. This is also often impractical.
  • The no preemption condition may also be impossible to remove as a process has to be able to have a resource for a certain amount of time or the processing outcome may be inconsistent.
  • The circular wait condition is the easiest to remove. A process may be allowed to possess only one resource at a time, or a ranking may be imposed such that no waiting cycles are possible. A hierarchy is typically used to determine a partial order between resources, but where no obvious hierarchy exists even the memory address of resources has been used to determine ordering between resources.