send(2) does not block, send(2) man page wrong?

Jan Grant Jan.Grant at bristol.ac.uk
Tue Jan 27 03:44:56 PST 2004


On Mon, 26 Jan 2004, Steve Watt wrote:

> julian at elischer.org wrote:
> >do what ping does (ping -f)
> >when you get an ENOBUFS do a usleep for 1 mSec.
> >and then send it again.
>
> So how, exactly, do you actually sleep for 1mSec?  I recently did some
> experiments using nanosleep(), and it seems that the minimum sleep time
> is 2 / HZ.  I.e. ask for 100nS, get 20mS (on a 10mS-ticking system).
>
> Mind you, that behavior is precisely aligned with what POSIX says should
> happen, since nanosleep() is not allowed to return success before the
> specified amount of time has expired, and you might be calling it 5nS
> before the clock tick.  But it does make doing correct Tx pacing a bit
> more challenging.

For what it's worth, when I tried this I wound up using gettimeofday
(IIRC) as a "macroscopic" clock and calculating nanosecond sleeps
between transmits; drift due to HZ was correctable because I knew the
average throughput I was after.

-- 
jan grant, ILRT, University of Bristol. http://www.ilrt.bris.ac.uk/
Tel +44(0)117 9287088 Fax +44 (0)117 9287112 http://ioctl.org/jan/
That which does not kill us goes straight to our thighs.


More information about the freebsd-hackers mailing list