timer->result
hi
#include<stdio.h>
#include<sys/time.h>
#include<time.h>
int main(void)
{
struct timeval t1,t2,result;
gettimeofday(&t1,NULL);
usleep(500);
gettimeofday(&t2,NULL);
timersub(&t2,&t1,&result);
printf("%ld",result.tv_usec);
}now technically i feel it should display 500 microsecond even not accurate then also it should show near by 500 or less than 600 microsecond atleast.
on my system it shows 40000 microsecond.... whats the reason? if i remove usleep then it shows 2 or 1 microsecond.....
whats wonrg here?
thanks
ankit
________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
Quoted 19 lines · On Tue, 28 Sep 2004 19:12:36 +0100 (BST) Ankit Jain <[email protected]>…
hi
#include<stdio.h>
#include<sys/time.h>
#include<time.h>int main(void)
{ struct timeval t1,t2,result; gettimeofday(&t1,NULL); usleep(500); gettimeofday(&t2,NULL); timersub(&t2,&t1,&result); printf("%ld",result.tv_usec); }now technically i feel it should display 500 microsecond even not accurate then also it should show near by 500 or less than 600 microsecond atleast.
Quoted 5 lines
on my system it shows 40000 microsecond.... whats the reason? if i remove usleep then it shows 2 or 1 microsecond.....
whats wonrg here?
Linux does not real time, and this calculation very approximetly...
Quoted 13 lines
thanks
ankit
________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 5 lines
Alphex Kaanoken, Senior Developer of Crew IT research labs. Web: http://crew.org.ru Mail: kaanoken at crew.org.ru