Hello all,
when I run the following programm
#include
#include
#include
void my\_usleep(unsigned int microseconds);
int main()
{
my\_usleep(1e6);
my\_usleep(1e5);
my\_usleep(1e4);
my\_usleep(1e3);
my\_usleep(1e2);
my\_usleep(1);
printf("Finished\n");
}
void my\_usleep(unsigned int microseconds)
{
clock\_t tick1=-1, tick2=-1;
double dClock = -1;
struct tms tStruct1, tStruct2;
if((tick1 = times(&tStruct1))== -1) printf("Error time 1\n");
usleep(microseconds);
if((tick2 = times(&tStruct2))== -1) printf("Error time 2\n");
if((dClock = sysconf(\_SC\_CLK\_TCK))
I get the following output:
usleep(1000000) takes 1010.00 ms
usleep(100000) takes 110.00 ms
usleep(10000) takes 20.00 ms
usleep(1000) takes 20.00 ms
usleep(100) takes 20.00 ms
usleep(1) takes 20.00 ms
Finished
Please, can anybody tell me why a usleep(1 usec) takes 20 ms ?
(Linux 2.4, glibc2.2, gcc 2.95.2)
Thanks
Lars