thread scheduling priority

Daniel Eischen eischen at vigrid.com
Mon Jul 7 11:42:12 PDT 2003


On Mon, 7 Jul 2003, Petri Helenius wrote:
> Daniel Eischen wrote:
> 
> >Mutexes are implemented using direct handoff (I think that's the
> >term).  Once a mutex is released, it is given to the next thread
> >that is waiting on it and that thread is then marked runnable.
> >Idle KSEs are suppose to be woken whenever there are runnable
> >threads.
> >  
> >
> So when the main thread unlocks the mutex there are two runnable threads,
> which one keeps running? 

The current thread.  As I said before, if there are idle KSEs, then
one is woken to run the newly runnable thread.

> 
> >For now, just see if things work better with 1 CPU defined.
> >If not, then all this talk about multiple KSEs isn't your
> >problem; it is something else.
> >  
> >
> It definetly runs a lot better, however not as good as I would expect if
> the running thread would be switched to the higher scheduling priority
> thread immediately on the mutex release. Should that happen or does
> it wait until the other thread hits  a blocking condition ?

It waits until either you hit a blocking condition or the
quantum expires.  The library is not (yet) smart enough
to switch out the current thread after the unlock if the
new owner has a higher priority.  We could do that, but
if there are other KSEs that can run the new thread, then
they should get it.

-- 
Dan Eischen



More information about the freebsd-threads mailing list