Subject: Re: usleep() accuracy?
To: Jukka Marin <jmarin@pyy.jmp.fi>
From: Bill Studenmund <wrstuden@nas.nasa.gov>
List: tech-kern
Date: 11/30/1999 10:32:33
On Tue, 30 Nov 1999, Jukka Marin 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.
Take care,
Bill