Fairness of thread scheduling?

Jason House jason.james.house at gmail.com
Tue Jun 5 15:17:57 PDT 2007


Sean Kelly wrote:
> Jason House wrote:
>>
>> Any ideas what could be going wrong?  I've tried adding a try block 
>> surrounding the run method of the worker threads to output any silent 
>> failures (somehow).  Since I see nothing failing and I see the 
>> decreased performance per thread, I'm assuming thread starvation is 
>> occurring.  Is this expected behavior?
> 
> I think the default scheduling option on Posix is implementation 
> defined.  The pre-defined options are FIFO and round-robin however, and 
> I'd guess your system is using FIFO?
> 
> 
> Sean

I don't even know how to find that information out.  In fifo, would an 
older thread get scheduled over a newer thread when both came up at the 
same for execution at the same time?  How would I look up if it's FIFO 
or round robin?


I tried it on windows today and thought I saw similar results.  There 
was definitely significant swings in how many ops/sec was reported in 
the output and starvation was occurring.  In a 4 thread test, only 
threads 1,2, and 3 gave output (0 didn't).  I didn't examine the data as 
closely as the first test on Mandriva, but I thought a similar effect 
(of different threads running at different speeds) was occuring.

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


More information about the Digitalmars-d-learn mailing list