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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to