No subject


Mon Apr 7 15:21:00 GMT 2003


>From ???@??? Thu Mar 06 20:08:19 2003
To: gcc-help@gcc.gnu.org
From: Ulrich Prakash <uprakash@npd.hcltech.com>
Subject: Re: Using the Intel's MMX Instruction Set in gcc3.2
Cc: Lars Segerlund <lars.segerlund@comsys.se>, fwyzard-gcc@libero.it
Bcc: 
X-Attachments: 
In-Reply-To: <5.1.0.14.0.20030306195206.03351c60@pilex>
References: 
Message-Id: <5.1.0.14.0.20030306195224.0334b310@pilex>

Hi All,

I want to sleep my program for around 20 miiliseconds period.
But usleep doesn't work correctly...

man page tells that usleep wud sleep for the microseconds time,but
when i gave usleep(1),it actually sleeps for 12000-14000
microseconds..

When i gave usleep(20000),it sleeps for 27000-29000microseconds
instead of 20,000...

I also tried using nanosleep,but nanosleep for 1 nanoseconds also
sleep for 12000-14000 microseconds.

Attaching the sample code also here...
/***** testusleep.c*********/
#include <sys/timeb.h>
#include <sys/time.h>
#include <time.h>
#include <math.h>

int main()
{

   struct timeval time1, time2;

   gettimeofday (&time1, 0x0);
   usleep (1);
   gettimeofday (&time2, 0x0);

   printf ("time difference in seconds is %ld\n", (time2.tv_sec -
time1.tv_sec));
   printf ("time difference in microseconds is %ld\n", (time2.tv_usec
- time1.tv_usec));

}

My pc detail is:
Pentium III(i686),701Mhz speed..
OS-Red Hat Linux7.2
gcc-version2.96

Please let me know if there is a way of achiveing a sleep for a
SPECIFIC precision value in milliseconds range...

Thanks,
Prakash.



More information about the Gcc-help mailing list