On Apr 17, 2006, at 2:56 PM, John M McIntosh wrote:
However now I see that this has changed to:
if (!aioPoll(0)) { struct timespec rqtp= { 0, realTimeToWait * 1000*1000 }; struct timespec rmtp; while ((nanosleep(&rqtp, &rmtp) < 0) && (errno == EINTR)) rqtp= rmtp; }
so why the change not to have the select() do the sleep?
Because select() cannot guarantee granularity of less than a timeslice once it has decided to go to sleep (hence the test just above that code for ms < timeslice quantum). You were sitting in my office when we proved this.
what are the conditions that would cause aioPoll() to return 0
No pending i/o activity on any open descriptors.
and if the nanosleep is invoked, would 16 ms pass before servicing a socket? if realTimeToWait is 16ms?
Not necessarily. If your kernel is clever enough to return early from nanosleep when a signal is delivered then socket i/o will have minimum latency. (On OSX this appears to be the case: nanosleep can return -1 and set errno to EINTR.)
Cheers, Ian