[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-serviceability-dev
Subject:    code review request for suspend/resume deadlock (6876794)
From:       gnu_andrew () member ! fsf ! org (Andrew John Hughes)
Date:       2009-09-21 22:13:37
Message-ID: 17c6771e0909211513t8df95d2m13241ee6a60f6598 () mail ! gmail ! com
[Download RAW message or body]

2009/9/21 Daniel D. Daugherty <Daniel.Daugherty at sun.com>:
>
>
> Andrew John Hughes wrote:
>>
>> 2009/9/21 Daniel D. Daugherty <Daniel.Daugherty at sun.com>:
>>
>>>
>>> Andrew John Hughes wrote:
>>>
>>>>
>>>> Assuming your analysis of the locking is correct (it sounds that way
>>>> to me), then this seems like a fairly straightforward patch.
>>>>
>>>
>>> So far no one has found any holes in the logic :-) But then again it
>>> took a few years to find this one :-)
>>>
>>>
>>
>> Concurrency problems tend to be like that. ?Code like this can be
>> difficult to get right, and still far too few people are even taught
>> good practice, never mind using it.
>>
>> MutexLocker seems to make things especially interesting, as there is
>> no explicit unlock call, it just happens as a side-effect of the
>> instance leaving scope and the destructor being called.
>>
>
> I guess I would argue that there is no explicit lock call either.
> That's the beauty of the helper object pattern. You allocate the
> helper object for the scope in which you need to hold the lock.
> No more. No less. No more forgetting to unlock. No more matching
> of lock and unlock calls.
>
> Dan
>
>

Yes, it's good in that respect, half the problem with locking is
placing lock/unlock statements at the correct points.  It just wasn't
that intuitive at first from the patch.  After reading through
MutexLocker.hpp it made sense.

You wouldn't want to use it with two dependent locks at the same scope
though, as you'd be relying on destructor ordering to make sure they
are unlocked in the correct order.
-- 
Andrew :-)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net

PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint: F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic