Safe Haskell | Trustworthy |
---|---|
Language | Haskell98 |
Automatic deadlock prevention.
Automatic deadlock detection is inefficient, and computations cannot be rolled back or aborted in general.
Instead, I prevent deadlocks before they happen.
Documentation
The typical sequence that produces a deadlock is as follows:
- Thread 1 acquires lock A
- Thread 2 acquires lock B
- Thread 1 tries to acquire B
- Thread 2 tries to acquire A
Deadlock.
Standard deadlock detection intervenes after (4) has occurred. I intervene in a lock acquisition that is followed by an unsafe schedule (here at (2)). I suspend thread 2 until a safe schedule is guaranteed -- in this case until thread 1 relinquishes lock A.
The Res arrow.
Computations are built with these constructors (and the arrow interface). Pieces of the arrow that hold locks have to be finitely examinable, Locks have to be used with the Acq and Rel constructors.