From: Michael Baloh <mjb5s@virginia.edu>
Subject: gettimeofday problems
Date: 1998/06/12 [thread overview]
Message-ID: <35817BB3.6E47EA3D@virginia.edu> (raw)
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++)
printf("\n%d %lu",sample_number,temp[sample_number]);
}
unsigned long sampleclock(void)
{
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 hardare
manegment
that i am unaware of? any advice would be appreciated
naihong wei
nw4n@virginia.edu
reply other threads:[~1998-06-12 4:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox