[zeromq-dev] Working with Windows timing resolution for select() timeouts
Steven McCoy
steven.mccoy at miru.hk
Tue Nov 9 20:21:00 CET 2010
Hi Martin,
I haven't run it through the ØMQ test programs, but here is the
explanation. On Windows the wait functions can have a 1ms resolution by
calling timeBeginPeriod(*1ms*), any time specified below 1ms will
immediately return and hence increase the likely hood of busy wait.
Therefore any timing for below 1ms should be rounded up to 1ms, but only on
Windows.
So pgm_socket.cpp has two lines along the form,
const long timeout = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
This will work better as follows,
const long timeout = (tv.tv_sec * 1000) + ((tv.tv_usec + 999) / 1000);
This will delay the PGM state engine for first iteration of recovery but
subsequent loops can busy wait to expediently manage additional timers.
--
Steve-o
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20101109/a635b631/attachment.htm>
More information about the zeromq-dev
mailing list