From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 27 03:44:55 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E497316A4CE for ; Tue, 27 Jan 2004 03:44:55 -0800 (PST) Received: from dire.bris.ac.uk (dire.bris.ac.uk [137.222.10.60]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7FAC943D1F for ; Tue, 27 Jan 2004 03:44:42 -0800 (PST) (envelope-from Jan.Grant@bristol.ac.uk) Received: from mail.ilrt.bris.ac.uk by dire.bris.ac.uk with SMTP-PRIV with ESMTP; Tue, 27 Jan 2004 11:43:53 +0000 Received: from cmjg (helo=localhost) by mail.ilrt.bris.ac.uk with local-esmtp (Exim 3.16 #1) id 1AlRaX-0004jC-00; Tue, 27 Jan 2004 11:41:01 +0000 Date: Tue, 27 Jan 2004 11:41:01 +0000 (GMT) From: Jan Grant X-X-Sender: cmjg@mail.ilrt.bris.ac.uk To: Steve Watt In-Reply-To: <200401262059.i0QKxdIi038551@wattres.Watt.COM> Message-ID: References: <200401262059.i0QKxdIi038551@wattres.Watt.COM> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: Jan Grant cc: hackers@freebsd.org cc: julian@elischer.org Subject: Re: send(2) does not block, send(2) man page wrong? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jan 2004 11:44:56 -0000 On Mon, 26 Jan 2004, Steve Watt wrote: > julian@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.