thread scheduling priority

Petri Helenius pete at he.iki.fi
Mon Jul 7 14:37:37 PDT 2003


> > 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.
>
Although I cannot prove this doesn´t 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.

Is there a delay for waking up the KSE? Obviously if neccessary
I can write a simple test program to spit out timestamps.
>
> 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.
>
I´ll test more soon and see if I can identify a reproducable issue.

Pete



More information about the freebsd-threads mailing list