Subject: Re: newlock
To: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
From: Garrett D'Amore <garrett_damore@tadpole.com>
List: tech-kern
Date: 09/03/2006 17:28:22
YAMAMOTO Takashi wrote:
>> The assumptions were that we would be dealing with two or more locks, with the
>> same SPL, and that the acquire and release would be done locally. That's not
>> general enough though. So, following your suggestion, something like this:
>>
>> 	mutex_enter(a);
>> 	.. find b ..
>> 	mutex_enter(b);
>>         mutex_link(b, mutex_exit_linked(a));
>>         .. update b ..
>>         mutex_exit(b);
>>
>> This is a part of the design I'm not comfortable with, and I think the above
>> is quite ugly. What do people think?
>>     
>
> what's wrong with using plain old splxxx() where out-of-order operation is
> really necessary?  i don't think it's often.
>
> YAMAMOTO Takashi
>   

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.

-- 
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