Boost logo

Threads-Devel :

From: Frank Mori Hess (fmhess_at_[hidden])
Date: 2008-04-13 13:01:17

I'm curious if there is any theory on how to avoid deadlock when using a
shared mutex? Having a well-defined locking order works well for an
ordinary mutex, but things get messy with a shared mutex. For example, if
we have mutexes A and B then the locking sequence

1) shared lock A
2) unique lock B
3) upgrade to unique lock A

will deadlock against

shared lock A (between steps 2 and 3 above)
unique lock B

it will also deadlock against

unique lock B (between steps 1 and 2 above)
unique lock A

however, it will not deadlock against

unique lock A
unique lock B


Threads-Devel list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at