Hi folks,
Due to my new found belief that all of the flaws in Wine are timing problems, I have found what appears to be a gaping hole in Wine's timing behavior.
Specifically, it appears as though any style of Waitxxx is supposed to yield the processor.
This seems a bit difficult for me to believe, even though we had earlier discovered that Wine was never yielding on a Sleep(0).
I've attached the test program I used to discover this. If you run sleep2 -1 0w the program will start 2 threads, one which spin loops (-1), and one which does a wait on an object for 0 seconds. You'll see in the results that the Wait(...,0) thread gets far fewer loops, and thus must be yielding.
Further, changing that to a 0ws (or even 5ws), which means we're waiting on a signalled object, doesn't change the behavior.
This leads me to suggest the attached patch.
I would appreciate review from other folks, because this seems like a drastic change to me, and it strikes me as equally likely that I've done something stupid.
Cheers,
Jeremy
Hmm. My own test program has a clear demonstration that this isn't quite right; a 'sleep2 -1 10we' shows that having an event trigger a wait gets the waiting thread some priority back.
This suggests that adding if (ret == WAIT_TIMEOUT) prior to the NtYieldExecution() gives the best results.
Jer