i'm sumbling on case waitforsingleobjectex timeout on event not returning "signalled", yet timeout has not passed.
specifically, debug issue in qt, changed this code:
bool qmutexprivate::wait(int timeout) { return (waitforsingleobjectex(event, timeout < 0 ? infinite : timeout, false) == wait_object_0); }
to code (which includes measurements):
bool qmutexprivate::wait(int timeout) { large_integer startingtime, endingtime, elapsedmicroseconds; large_integer frequency; queryperformancefrequency(&frequency); queryperformancecounter(&startingtime); auto result = (waitforsingleobjectex(event, timeout < 0 ? infinite : timeout, false) == wait_object_0); queryperformancecounter(&endingtime); elapsedmicroseconds.quadpart = endingtime.quadpart - startingtime.quadpart; elapsedmicroseconds.quadpart *= 1000000; elapsedmicroseconds.quadpart /= frequency.quadpart; if (!result && timeout > 0) std::cerr << "waited " << elapsedmicroseconds.quadpart << " microseconds when asked " << timeout << std::endl; return result; }
where event
created via createevent(0, false, false, 0);
.
stressing code path prints statements like:
waited 96734 microseconds when asked 100 msecs
is waitforsingleobjectex allowed wake early, is, before specified timeout (due timer coalescence in kernel or similar technologies), or should investigate problem elsewhere? documentation not me clarifying this.
msdn on wait functions , time-out intervals:
the accuracy of specified time-out interval depends on resolution of system clock. system clock "ticks" @ constant rate. if time-out interval less resolution of system clock, the wait may time out in less specified length of time. if time-out interval greater 1 tick less two, wait can anywhere between 1 , 2 ticks, , on.
to increase accuracy of time-out interval wait functions, call timegetdevcaps function determine supported minimum timer resolution , timebeginperiod function set timer resolution minimum. use caution when calling timebeginperiod, frequent calls can affect system clock, system power usage, , scheduler. if call timebeginperiod, call 1 time in application , sure call timeendperiod function @ end of application.
Comments
Post a Comment