Deadlock

A deadlock ( deadlock in English) is a phenomenon which can occur in concurrent Programmation. Deadlock occurs when two light Processus S ( thread ) competitor expect mutually. The processes blocked in this state are it definitively, it thus acts of a catastrophic situation. It is E.G Coffman (1971 Engraved St) mainly which studied the mechanisms leading to the phenomena of deadlock.

Examples

A concrete example of deadlock can occur when two light Processus S try to acquire two bolts in a different order. Thus, if for example there are two Mutex (named M1 and M2) and the two following light processes:

A deadlock is possible. Indeed, if for example, the sequence of following operation occurs:

  1. the TâcheA obtains M1.
  2. the TâcheB obtains M2.
  3. the TâcheA waits to obtain M2 (which is between the hands of TâcheB).
  4. the TâcheB waits to obtain M1 (which is between the hands of TâcheA).

In this situation, the two tasks (TâcheA and TâcheB) are definitively blocked.

Solutions to avoid deadlocks

There does not exist any solution making it possible to avoid all deadlocks. It is on the other hand possible to take measures to limit the risk of deadlock, to start with a very precise analysis of the application to write.

A method consists with always acquiring the Mutex (mutual exclusion) in the same order. Indeed, if several light Processus S ( thread ) requires to acquire several bolts to carry out their work, if they acquire the bolts in a different order, it is possible that they are blocked at the time of the sequence of acquisition (as in the preceding example).

It is also advisable to be interested in the priorities of the processes. Indeed, if for example a process of high priority in common uses a bolt with a basic process priority (see also Inversion of priority), it is possible to obtain blockade situations. A solution with this kind of problem consists in using bolts only between of the same processes priority.

Reference

  • Luigi Zaffalon and Pierre Breguet, concurrent Programming and real-time with ADA 95 , polytechnic Presses and French academics, Lausanne, 1999

Random links:Emile Boutroux | Cathedral of Uppsala | Jason Scotland | List secessionist popes | Zyb | Gwathló