Subject: Re: So I'll bite. M:N w/o SA - how?
To: None <tech-kern@netbsd.org>
From: Joerg Sonnenberger <joerg@britannica.bec.de>
List: tech-kern
Date: 02/22/2007 14:30:51
On Wed, Feb 21, 2007 at 11:40:24AM -0800, Bucky Katz wrote:
> Bill Studenmund <wrstuden@netbsd.org> writes:
> > When a thread blocks in the kernel, you'd like to run something else on 
> > that thread, no?
> 
> Yes. This is why I don't believe you can accomplish this entirely in
> userland.

That's the point where I disagree. I do not think it is necessary to do
that or even helpful. Let blocking events block the lwp.  When you took
the time for a trap, the context switching overhead is reasonably small.

What needs support in the kernel is a better/faster upcall and the
interaction with the scheduler for the case of all threads being
blocked. Whenever the kernel switches to such a lwp, it can stashes an
upcall for the program scheduler in. That can decide whether to continue
running the thread before or switching to a different one. Optionally,
the lwp could inform the kernel were to save the register set and which
to load, thereby avoiding the double saving issues. The impact in the
kernel is small, but for the common problems of heavy synchronisation
most of the context switches can be done entirely in userland and
reduced to the callee-saved registers. Add syscall-less time functions
and you know where I want to arrive at :-)

Joerg