thread scheduling priority

Daniel Eischen eischen at vigrid.com
Mon Jul 7 15:53:37 PDT 2003


On Tue, 8 Jul 2003, Petri Helenius wrote:

> > > So when the main thread unlocks the mutex there are two runnable thre=
ads,
> > > 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.
> >
> Although I cannot prove this doesn=B4t happen, I think the other
> thread does not get scheduled until a few moments later because
> when I get the scenario where thread1 has the mutex, thread2
> is waiting on it, thread1 goes to cpu-bound tasks without
> holding the mutex, thread2 is not woken up, at least not immediately.

The KSE is woken immediately, but you are at the
whimsy of the kernel scheduler.  Depending on what
else is running, the woken KSE may not run right
away.

You can see the wakeups using ktrace...

--=20
Dan Eischen



More information about the freebsd-threads mailing list