// // main.m // sleepy-sleep // // Created by Gilbert Baumann on 2021-08-12. // Copyright © 2021 Gilbert Baumann. All rights reserved. // #include #include #include #import pthread_t sleeper; void *sleeper_main (void *ignore) { struct timeval tv; double t1, t2; (void)ignore; for (;;) { useconds_t q = 100 * 1000; sleep (10); gettimeofday (&tv, NULL); t1 = tv.tv_sec + tv.tv_usec * 1e-6; usleep (q); gettimeofday (&tv, NULL); t2 = tv.tv_sec + tv.tv_usec * 1e-6; printf ("usleep(%lld) took %fs\n", (long long)q, t2 - t1); } } int main(int argc, const char * argv[]) { pthread_create (&sleeper, NULL, sleeper_main, NULL); return NSApplicationMain(argc, argv); }