Subject: Re: CVS commit: src/lib/libpthread
To: Gary Duzan <gary@duzan.org>
From: Nathan J. Williams <nathanw@wasabisystems.com>
List: source-changes
Date: 04/16/2003 22:47:46
Gary Duzan <gary@duzan.org> writes:
> =>When a thread sleeps on a mutex or cv, have it put itself on the
> =>front of the sleep queue rather than the back. This is more
> =>cache-friendly behavior and within the (lack of) constraints on wakeup
> =>ordering imposed on equal-priority threads.
>
> Does this introduce a greater likelihood of starving other
> waiting threads? Perhaps it would make sense to do something like
> putting the thread on the back of the queue every kth sleep (which
> could be randomly selected, or via a counter), just to give any
> other waiting threads a shot.
It does increase the risk of starvation. I don't consider this a
problem; there is no guarantee, anywhere, that mutexes and cv's
provide any kind of fairness, not that such a thing is even well
defined.
You can build 'fair' scheduling on top of fast mutexes and cv's. You
can't build fast on top of 'fair'.
- Nathan