Subject: Re: newlock
To: Andrew Doran <ad@NetBSD.org>
From: Garrett D'Amore <garrett_damore@tadpole.com>
List: tech-kern
Date: 09/03/2006 19:31:55
Andrew Doran wrote:
> Hi Garrett,
>
> On Sun, Sep 03, 2006 at 05:28:22PM -0700, Garrett D'Amore wrote:
>
>
>> What's wrong with the standard solaris way of doing this?
>>
>> mutex_enter(a);
>> find b...
>> mutex_enter(b);
>> /* possibly unlock a now *
>> mutex_exit(b);
>> mutex_exit(a); /* unless you did it earlier */
>>
>> It gives full flexibility, and keeps everything explicit.
>>
>
> If releasing spin mutexes out of order, then we restore the saved SPL too
> early and there's a short window where an interrupt can fire and we deadlock
> on the mutex:
>
> mutex_enter(a) <- original interrupt mask saved
> mutex_enter(b)
> ...
> mutex_exit(a) <- original interrupt mask restored
> mutex_exit(b) <- deadlock
>
> The question is: how to allow that cleanly? I don't know how Solaris handles
> that with spin mutexes. From what I know, I doubt it does..
>
Wrong. This works fine in Solaris. The spin mutex doesn't
automatically release the spl -- instead it releases a _reference_ on
the spl. The spl is only dropped when the reference reaches zero.
-- Garrett
> Thanks,
> Andrew
>
--
Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
http://www.tadpolecomputer.com/
Phone: 951 325-2134 Fax: 951 325-2191