Subject: Re: usleep() accuracy?
To: Bill Studenmund <wrstuden@nas.nasa.gov>
From: Jukka Marin <jmarin@pyy.jmp.fi>
List: tech-kern
Date: 11/30/1999 21:32:14
On Tue, Nov 30, 1999 at 10:32:33AM -0800, Bill Studenmund wrote:
> > How accurate is usleep() on i386 (NetBSD-release)?  Thanks to the PC UARTs,
> > I have to poll the CTS input in software to prevent overflowing input buffer
> > of some special hardware (the PC UART always transmits whatever it has in
> > FIFO, even if the CTS input tells it to STOP).  I'm using a loop with
> > usleep(4000), ioctl() to poll the CTS state and write() to output a new
> > byte if CTS is high (4 ms would be a good delay for this baud rate).
> > However, according to my oscilloscope, I'm actually transmitting bytes at
> > 20 ms intervals which in turn causes a data underflow in the external
> > hardware..
> 
> Wouldn't it just be easier to hack the driver to only put one byte into
> the fifo at a time, rather than polling? You'd up the interrupt rate to
> about 250 per second (assuming one byte about every 4 ms), but that's not
> bad.

Probably so, but that would affect all serial ports (I have six of them
at the moment).  In addition, I'm only using NetBSD for testing the
software of the external device - in the final application, the hardware
will be driven by an embedded system (which does not exist yet).

  -jm