A
Alexander Terekhov
Michael Podolsky wrote:
[... m1.unlock() "sequenced before" m2.lock() reordering ...]
Both are the same in the sense that reordering is happening in
deadlock-free manner (executing thread won't wait for m2 while holding
m1 locked).
The following can not be reordered (reordering in whatever manner may
not be observed):
m1.lock() "sequenced before" m2.lock()
m1.lock() "sequenced before" m2.unlock()
m1.unlock() "sequenced before" m2.unlock()
Reordering of m1.unlock() "sequenced before" m2.lock() may be observed
using (sane) trylock().
regards,
alexander.
[... m1.unlock() "sequenced before" m2.lock() reordering ...]
May be I am not completely following your idea. Is there any important/
significant difference between what you are proposing to do with
lock_but_if_blocked_unlock_another and between my code which looked
like:
Both are the same in the sense that reordering is happening in
deadlock-free manner (executing thread won't wait for m2 while holding
m1 locked).
The following can not be reordered (reordering in whatever manner may
not be observed):
m1.lock() "sequenced before" m2.lock()
m1.lock() "sequenced before" m2.unlock()
m1.unlock() "sequenced before" m2.unlock()
Reordering of m1.unlock() "sequenced before" m2.lock() may be observed
using (sane) trylock().
regards,
alexander.