gettimeofday problems

gettimeofday problems

Post by Michael Balo » Sat, 13 Jun 1998 04:00:00



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++;

Quote:}
}

for(sample_number=0;sample_number<1000;sample_number++)
printf("\n%d  %lu",sample_number,temp[sample_number]);

Quote:}

 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;

Quote:}

basically, are there any particular details involves in hardare
manegment
that i am unaware of? any advice would be appreciated

naihong wei

 
 
 

1. gettimeofday problems

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

michael baloh

2. Windows NT Server (SP3) <--------> Linux Samba 1.9.18p8

3. Date and gettimeofday problem

4. KWord - Inline Frame

5. gettimeofday problem

6. Qualix FirstWatch H/A Software

7. gettimeofday(struct timeval *tp) but is in 2.4 gettimeofday(tp,tzp)

8. Netbsd in ZIP

9. Problems with Solaris gettimeofday() or localtime()

10. 2.5 emacs-19.30 gettimeofday configure/compile problem

11. gettimeofday compile problem

12. Problem hooking "system" call gettimeofday()/ST_GETHRESTIME/ta 0x27

13. Problem linking to gettimeofday function