
21 Aug
2013
21 Aug
'13
7:41 p.m.
El 21/08/2013 17:43, Peter Dimov escribió:
But the timeslice is not necessarily 20ms. A call to timeBeginPeriod(1) may shorten it.
timeBeginPeriod seems a bit scary as it affects the general windows scheduler. One option could be to call GetTickCount until it changes its value twice (as the resolution of this time is the resolution of the system timer). Once it changes (after 20-40ms looping, on average that would me 30ms), then Sleep(1) is called. And for uniprocessor systems we should avoid doing any loop and call only Sleep(0). But that would be a really hard to implement spinlock ;-) Another option is to obtain the a high resolution timestamp each loop and just loop, say, for 100ms before going to Sleep(1). Best, Ion