Boost logo

Threads-Devel :

From: Frank Mori Hess (fmhess_at_[hidden])
Date: 2007-07-23 21:10:39


On Monday 23 July 2007 03:22, Anthony Williams wrote:
> I have code for a mutex that checks for deadlock at runtime --- every
> thread that tries to lock a checked mutex registers that it is waiting
> for that mutex, and then when the lock is acquired it flags the mutex to
> identify the owning thread. When a thread registers that it is waiting
> on a mutex, the chain is followed --- which thread currently owns the
> mutex? Is it waiting on another mutex? and so forth, until we either
> reach a thread that is not waiting (we're fine), or a thread that is
> waiting on a mutex owned by the original thread (deadlock).

That seems like a complementary idea. It doesn't detect deadlocks unless
they actually occur, but can immediately produce information on exactly
how the deadlock happened.

> I also have an incomplete prototype of a "levelled" mutex --- each mutex
> is assigned a level, and threads may only lock a mutex with a higher
> level than any currently locked. This enforces an ordering on mutex
> locks, which will therefore prevent deadlock. It is not something that
> is usable in every situation, though.

That would avoid the potentially large overhead of analyzing my directed
graph for cycles. I wonder if there's a good way to dynamically assign
levels to mutexes as they are added to the graph.

-- 
Frank



Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk