Subject: Re: Mutex question
To: Steven M. Bellovin <smb@cs.columbia.edu>
From: Garrett D'Amore <garrett_damore@tadpole.com>
List: tech-kern
Date: 03/16/2006 08:55:47
Steven M. Bellovin wrote:
> On Thu, 16 Mar 2006 09:16:57 -0500 (EST), Matthew Orgass
> <darkstar@city-net.com> wrote:
>
>   
>> On 2006-03-16 hselasky@c2i.net wrote:
>>
>>     
>>> If I want to aquire a mutex from:
>>>
>>> 1) Interrupt handler
>>> 2) Callout (timeout)
>>>
>>> How do I do that? Do I have to use a soft interrupt handler?
>>>       
>>   No, you just need to use the right spl calls to block the hard interrupt
>> in the callout (placed outside the lock).
>>
>>     
>
> The question is this: what do you do in the interrupt handler or
> timeout if you can't get the mutex?  You can't sleep; there's no
> process context.
>   

This is where "locks" should have an interrupt cookie with them, so that
acquiring a lock results in the spl being set appropriately.  The user
of the lock should have to declare this usage at lock initialization time.

I've not looked at the lock infrastructure in NetBSD yet, so I don't
know if we follow this principle or not.  But without it, locks are
basically useless for synchronization with interrupt handlers.

    -- Garrett

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