Subject: Re: Interrupt, interrupt threads, continuations, and kernel lwps
To: Andrew Doran <ad@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 06/21/2007 08:07:24
On Wed, Jun 20, 2007 at 10:54:14PM +0100, Andrew Doran wrote:
> What I mean is that from a hardware ISR that does not have thread context
> (like at IPL_NET) it wouldn't be possible to call callout_reset() or similar
> functions. That would need to be deferred to a soft interrupt or a kernel
> thread.
Uggg... wouldn't it be possible to be able to specify a PL level at
which a callout function will run?
That would allow such callouts to be used from WH interrupts.
SPL locking the callout table shouldn't be a problem.
> That may well make sense. There is the potential to cause a deadlock by
> maniuplating a callout when holding a lock that the callout routine wants
> to grab:
I know ...
> resetit()
> {
> mutex_enter(&lock);
> callout_reset(&ch, 1, mycallout, myarg);
> ^ blocks waiting for mycallout()
> mutex_exit(&lock);
> }
>
> mycallout()
> {
If the ISR happens here, then try_callout_reset() would fail, but the ISR
could set state.
> mutex_enter(&lock);
> /* do stuff */
> mutex_enter(&lock);
If the ISR happens here, the 'do stuff' above should have marked the
callout as 'not pending'.
> }
David
--
David Laight: david@l8s.co.uk