poll/select: prevent busy-waiting
authorPaolo Bonzini <bonzini@gnu.org>
Mon, 21 May 2012 07:52:42 +0000 (09:52 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 22 May 2012 08:11:38 +0000 (10:11 +0200)
commita2292d4ccb2bba35b010c5cbd0354345a35568fa
tree43888a8912c82b54e18d379828b2dbcf72ecc380
parent7e2a535f8c362d5d3905cac9ebd7df4622604992
poll/select: prevent busy-waiting

2012-05-21  Paolo Bonzini  <bonzini@gnu.org>

poll/select: prevent busy-waiting.  SwitchToThread() only gives away
the rest of the current time slice to another thread in the current
process. So if the thread that feeds the file decscriptor we're
polling is not in the current process, we get busy-waiting.
* lib/poll.c: Use SleepEx(1, TRUE) instead of SwitchToThread().
Patch from Theodore Leblond.
* lib/select.c: Split polling out of the loop that sets the output
fd_sets.  Check for zero result and loop if the wait timeout is
infinite.
ChangeLog
lib/poll.c
lib/select.c