Date: Mon, 6 Aug 2001 10:49:05 -0700 From: Jeff Behl <jeff@expertcity.com> To: "'freebsd-hackers@freebsd.org'" <freebsd-hackers@freebsd.org> Subject: timing question Message-ID: <0307F3737A2AD511A42200D0B7A071919A402F@dopey.corp.expertcity.com>
next in thread | raw e-mail | index | archive | help
please excuse and direct me to the right place if this isn't the appropriate place to post this sort of question.... we're looking into moving to freebsd (yea!), but found the following problem. It seems that the shortest amount of time the below code will sleep for is 20 seconds! any call to nanosleep for 5,10, etc miliseconds returns a 20 ms delay. are we doing something wrong? thanks jeff typedef int64_t INT64; INT64 start = getMilliseconds(); struct timespec tspec; tspec.tv_sec = 0; tspec.tv_nsec = 5*(1000*1000); // millisconds -> nanoseconds nanosleep(&tspec, NULL); INT64 end = getMilliseconds(); INT64 elapsed = end - start; //return time in microseconds. INT64 getMilliseconds() { struct timeval tp; gettimeofday( &tp, NULL ); return (INT64)tp.tv_sec * 1000 + ((INT64)tp.tv_usec)/1000; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0307F3737A2AD511A42200D0B7A071919A402F>