Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/lib/libpthread



Gary Duzan <gary%duzan.org@localhost> 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




Home | Main Index | Thread Index | Old Index