Boost logo

Boost :

Subject: Re: [boost] [interprocess] locked mutex and process killed
From: Edouard A. (edouard_at_[hidden])
Date: 2009-03-25 04:53:39


On Wed, 25 Mar 2009 11:40:29 +0300, Dmitry Goncharov
<dgoncharov_at_[hidden]>
wrote:

> Even in this situation you can do something. After a thread (or a
> process) which holds a mutex locked gets killed any attempt to unlock
> the mutex
> will (and should) fail with EPERM. To resume using the mutex you can
> initialize it again. In other words, you can invoke pthread_mutex_init()
> on this mutex. This will unlock the mutex for you.
> This is sort of a dirty trick. If a thread had a mutex locked when it
> was killed it is very likely that the data (that the mutex protects) is
> in some inconsistent state. So, besides unlocking the mutex (by the
> means of pthread_mutex_init()) you also have to restore the data.

Yes, if you know that the mutex is abandoned in the first place, which
requires robust mutexes, if I understood correctly.

I think that there is no Windows specific implementation of interprocess
mutex. This could be useful since the API guarantees you to return
WAIT_ABANDONED when you wait on a mutex in this case. It's not a lot of
work, I offer my help if needed.

-- 
EA

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk