Subject: Re: newlock
To: Garrett D'Amore <garrett_damore@tadpole.com>
From: Garrett D'Amore <garrett_damore@tadpole.com>
List: tech-kern
Date: 09/04/2006 13:35:02
David Laight wrote:
> On Sun, Sep 03, 2006 at 07:31:55PM -0700, Garrett D'Amore wrote:
>   
>> 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.
>>     
>
> I've never seen that behaviour documented for Solaris...
>   

It wouldn't be "documented", because that would be an internal
implementation detail.

I'm now looking the code, and I'm not so sure.  I had always assumed it
this to be this way, but reading the Solaris code, it looks like I could
be wrong here.  If that's true, then there are a lot of buggy Solaris
drivers out there, including one or two that I've written. :-(

I'm going to investigate this further.


> OTOH the last solaris drivers I wrote were for 2.5 or 2.6.
> I also remember it being an absolute pain that you couldn't mask interrupts
> unless yoiu were in the driver that attached t hISR.
>   

Masking interrupts doesn't work on very high end SMP hardware.  You're
still trying to design for systems with less than 8 CPUs.

The only reason you want to block an interrupt is to keep an ISR from
clobbering some shared state.  So you have a mutex that has the iblock
cookie set, which blocks the interrupt for you.  You can acquire these
mutexes anywhere (except a higher priority ISR than what you declared at
mutex creation time!)

The system takes care of ensuring that the ISR can't run during this time.

"Masking interrupts" is the old BSD uniprocessor way of thinking. 
Solaris is better.  Trust me.

    -- Garrett
> 	David
>
>   


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