[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[off topic] A pause in C?



I am after a way to generate a pause of 300ns in a C program I am working
on. At the moment, I am using a for loop of about 700000 iterations..
works okay, but on a faster system it will die.. (needed to slow down I/O
with an interface card)
I was looking at the info page for libc (which seems to be broken.. I cant
go to other nodes from 'info libc') and found the timeval structure. It
looks like what I want, but I cant work it out.. can someone help?

something like:

void p_300ns()
{
  struct timeval interval;

  // assign interval its members here.. ??
  
  long int start = interval->tv_usec;

  do {
    // assign interval its members here again
  } while interval->tv_usec < start + 3<some zero's>;

  // have to excuse my memory..      ^^^^^^^^^^^^^^^  what is nano ? micro
  // is one millionth, nano is one something thousandth.. ??

}


                       Michael Beattie (mickyb@es.co.nz)

               PGP Key available, reply with "pgpkey" as subject.
 -----------------------------------------------------------------------------
                   Drive nail here ( ) to need a new monitor.
 -----------------------------------------------------------------------------
                Debian GNU/Linux....  Ooohh You are missing out!





Reply to: