Hi,
Nanosleep in the iOS simulator ( running on MacOS Sierra with xcode 8.1 & 8.2beta ) sleep around 5 times longer than the desired duration.
This doesn't happen on the iPhone 7 or natively in macOS sierra app, only in the simulator.
Is it possible to have more accurate sleep duration in the simulator or is it a bug ?
struct timespec request;
request.tv_sec = 0;
request.tv_nsec = 17000000;
mach_timebase_info_data_t base;
mach_timebase_info(&base);
while (1) {
uint64_t start, end, elapsed;
start = mach_absolute_time();
nanosleep(&request, NULL);
end = mach_absolute_time();
elapsed = (end - start) / base.denom;
printf("Sleep = %f msec\n", elapsed * 1E-6);
} Output:
Sleep = 84.451425 msec
Sleep = 69.947846 msec
Sleep = 95.484521 msec
Sleep = 72.795438 msec
Sleep = 80.162972 msec
Sleep = 70.265713 msec
...