SMPing libpthread

Daniel Eischen eischen at pcnet1.pcnet.com
Thu Apr 24 23:26:50 PDT 2003


On Fri, 25 Apr 2003, David Xu wrote:
> ----- Original Message ----- 
> From: "Daniel Eischen" <eischen at pcnet1.pcnet.com>
> To: "David Xu" <davidxu at freebsd.org>
> Cc: <freebsd-threads at freebsd.org>
> Sent: Friday, April 25, 2003 11:07 AM
> Subject: Re: SMPing libpthread
> 
> 
> > On Thu, 24 Apr 2003, David Xu wrote:
> > 
> > > I have put a patch to enable userland support SMP scheduling. 
> > > http://people.freebsd.org/~davidxu/libpthread_smp.diff
> > > The patch works on my SMP machine, but not fully tested,
> > > and I will work on idle kses stuffs. At least, it seems
> > > the SMP speed is not slower than UP. :-)
> > 
> > Cool, I just found the bug with scope process threads that was
> > causing Token_Strategy_Test to fail.  Now the 2 ACE tests that
> > were SIGBUS'ing (with scope system threads enabled) are now
> > running.  Only Token_Strategy_Test fails, but it is just an
> > expected result where some mean value is less than the stddev.
> > 
> >   http://people.freebsd.org/~deischen/kse/libpthread.diffs
> > 
> > I was willing to work on the idle KSEs; I was just asking
> > your opinion :-)  Feel free to tackle it though.
> > 
> I have a simple idea, in kse_wait(), a kse inserts itself into
> an idle kse queue under scheduler lock held(it is already), 
> then release scheduler lock and call kse_release(). any
> other kses enters in _thr_sched_multi and got a completed context 
> list should look the idle kses queue and wakeup those idle kses
> accordingly, also _thr_set_runnable_unlocked etc should look
> the idle queue as well, because all things are done under scheduler
> lock, it seems very nice for me. :-)

Yeah, very similar to what I was going to do.  I was just
going to increment the KSEG's kg_idle_kses and add an idle flag
to the KSE (and set it in kse_wait()).  The KSE's are already
in a list hung off the KSEG, so you could just walk the list
until you found an idle KSE to wakeup.  But you could add another
"idle KSE" list just as well.

I also thought about adding a _pq_count() (or _pq_depth())
function to the priority queues.  So you can tell if there
is more than one thread.  There's no sense in waking idle
KSEs if there's not enough runnable threads for them to run.

-- 
Dan Eischen



More information about the freebsd-threads mailing list