hello,
i am trying to access the clock time via 'gettimeofday' for a real time
application. this application works correctly for i386 machines, but
performs poorly for Linux version 2.0.32 alpha w/ gcc version 2.7.2.3.
the problem manifests itself in this way. i use 'gettimeofday' to acces
the system clock. however, the state of the clock does not change every
micro second but abaout every 980usec.! i have included the essential
piece of code below that i using to perform this test
unsigned long sampleclock(void);
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h> /* for sleep and usleep */
#include <math.h> /* for pow() */
/* now include some special headers */
#include <asm/io.h> /* for inw, inb, outw, outb, ioperm */
#include <sched.h>
#include <sys/time.h>
#define maximum_sample_number 2000
unsigned long t1,t2,temp[maximum_sample_number];
main()
{
t1=sampleclock();
while(sample_number<1000)
{
t2=sampleclock();
if(t2!=t1)
{
temp[sample_number]=t2;
t1=t2;
sample_number++;
for(sample_number=0;sample_number<1000;sample_number++)Quote:}
}
printf("\n%d %lu",sample_number,temp[sample_number]);
unsigned long sampleclock(void)Quote:}
{
struct timeval ttt, (*t)=(&ttt);
struct timezone zzz, (*z)=(&zzz);
/* sample the clock */
gettimeofday(t,z);
/* Convert everything to microseconds */
return 1000000 * t->tv_sec + t->tv_usec;
basically, are there any particular details involves in hardareQuote:}
manegment
that i am unaware of? any advice would be appreciated
naihong wei