Usenet comp.os.linux.alpha (1997-2013)
 help / color / mirror / Atom feed
* gettimeofday problems
@ 1998-06-12  4:00 Michael Baloh
  0 siblings, 0 replies; only message in thread
From: Michael Baloh @ 1998-06-12  4:00 UTC (permalink / 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




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-06-12  4:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-06-12  4:00 gettimeofday problems Michael Baloh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox