Fairness of thread scheduling?

Sean Kelly sean at f4.ca
Tue Jun 5 19:06:38 PDT 2007


Jason House wrote:
> 
> I could have sworn that given equal usage needs, kernels (regardless of 
> OS) would be fair among the threads if they were equal priority.

That's basically true, but synchronization points affect things.  Kernel 
calls and such all risk a premature context switch if the executing 
thread cannot proceed immediately.  IO tends to involve a mutex at some 
level, for example, not to mention IO buffer limitations.  The best was 
to be sure your threads are consuming every cycle they're allotted is to 
stay entirely in user code.

As for determining the default scheduling scheme--I checked the 
OpenGroup POSIX spec, hoping to find something obvious.  I remember 
seeing mention of it before, but couldn't find it again in the time I 
had to look.  Similar information is available for Windows somewhere in 
MSDN, but finding it would take some time as well.


Sean


More information about the Digitalmars-d-learn mailing list