login
Header Space

 
 

Re: Interrupt, interrupt threads, continuations, and kernel lwps

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Bill Studenmund <wrstuden@...>
Cc: <jonathan@...>, <tech-kern@...>
Date: Thursday, February 22, 2007 - 4:54 pm

On Thu, Feb 22, 2007 at 09:46:42AM -0800, Bill Studenmund wrote:


Exactly. We already context switch for interrupts, but it is not the same as
mi_switch. What I want to do is give the interrupt handler enough context
(curlwp, stack) that it can block briefly and be restarted later. There are
two outcomes: the interrupt runs to completion, or the handler blocks. In
both of those cases, we return back to the interrupted LWP just as we do
now.

The handlers would be permitted to block only in order to acquire a mutex or
RW lock. Calling cv_wait(), or lockmgr() or pool_get(, PR_WAITOK) etc. from
the handler's context would panic the machine.

When the lock a handler is waiting on is released, we end up in sleepq_wake.
The interrupt handler gets marked runnable and put onto a per-CPU run queue.
Just before returning, sleepq_wake notices that there is a high priority LWP
(above system or kernel priority) waiting to run and calls preempt. The
interrupt handler is the highest priority item in the run queue, so it gets
picked and put back on the CPU.

What Jonathan is describing is roughly how FreeBSD works, I think. When the
interrupt comes in, mi_switch() is called to dispatch it. The thread that
was running when the interrupt came in gets kicked off the CPU.

Andrew
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: Interrupt, interrupt threads, continuations, and kernel ..., Joerg Sonnenberger, (Thu Feb 22, 5:59 pm)
Re: Interrupt, interrupt threads, continuations, and kernel ..., Andrew Doran, (Thu Feb 22, 4:54 pm)
Re: Interrupt, interrupt threads, continuations, and kernel ..., Steven M. Bellovin, (Wed Feb 21, 10:21 pm)
speck-geostationary