Bug: Dead Lock

With multithreaded (parallel execution) or asynchronous programmes, there is a risk of a system entering a blocked state. A deadlock describes such a state in which several processes are waiting for resources that are held by other processes. This creates a cycle of mutual dependencies in which none of the processes involved can progress, as each is dependent on the release of resources by other processes.

For example:

In human terms, it could look like this:

What avoidance/mitigation options are available

  • Define a fixed sequence in which resources are requested to avoid cyclical dependencies.
  • Use time limits for resource accesses to automatically terminate stalled processes.
  • Reduce the need for locking by using lock-free data structures or atomic operations.
  • Minimise resource usage and avoid simultaneous requests for multiple resources by the same process.
  • Implement mechanisms to react to deadlock situations, e.g. terminating an affected process.