From owner-freebsd-hackers Mon Aug 6 10:48:23 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from dopey.corp.expertcity.com (host1.expertcity.rangefire.net [216.64.159.146]) by hub.freebsd.org (Postfix) with ESMTP id F2D4A37B403 for ; Mon, 6 Aug 2001 10:48:18 -0700 (PDT) (envelope-from jeff@expertcity.com) Received: by dopey.corp.expertcity.com with Internet Mail Service (5.5.2653.19) id ; Mon, 6 Aug 2001 10:49:06 -0700 Message-ID: <0307F3737A2AD511A42200D0B7A071919A402F@dopey.corp.expertcity.com> From: Jeff Behl To: "'freebsd-hackers@freebsd.org'" Subject: timing question Date: Mon, 6 Aug 2001 10:49:05 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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