[zeromq-dev] Working with Windows timing resolution for select() timeouts
Martin Sustrik
sustrik at 250bpm.com
Wed Nov 10 10:39:23 CET 2010
Steve,
Thanks! I'll apply the patch shortly.
Martin
On 9/11/2010, "Steven McCoy" <steven.mccoy at miru.hk> wrote:
>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
More information about the zeromq-dev
mailing list