From owner-freebsd-hackers Thu Mar 13 22:35:30 2003 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 2CD8B37B401 for ; Thu, 13 Mar 2003 22:35:29 -0800 (PST) Received: from cirb503493.alcatel.com.au (c18609.belrs1.nsw.optusnet.com.au [210.49.80.204]) by mx1.FreeBSD.org (Postfix) with ESMTP id E0A6F43F3F for ; Thu, 13 Mar 2003 22:35:27 -0800 (PST) (envelope-from peterjeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1]) by cirb503493.alcatel.com.au (8.12.6/8.12.5) with ESMTP id h2E6ZPiM009930; Fri, 14 Mar 2003 17:35:26 +1100 (EST) (envelope-from jeremyp@cirb503493.alcatel.com.au) Received: (from jeremyp@localhost) by cirb503493.alcatel.com.au (8.12.6/8.12.5/Submit) id h2E6ZHfq009929; Fri, 14 Mar 2003 17:35:17 +1100 (EST) Date: Fri, 14 Mar 2003 17:35:16 +1100 From: Peter Jeremy To: Enache Adrian Cc: David Cuthbert , hackers@FreeBSD.ORG Subject: Re: first parameter to select Message-ID: <20030314063516.GA9301@cirb503493.alcatel.com.au> References: <3E702BCC.3030208@kanga.org> <20030313083710.GA8225@cirb503493.alcatel.com.au> <20030313165018.GA703@ratsnest.hole> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030313165018.GA703@ratsnest.hole> User-Agent: Mutt/1.4i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Mar 13, 2003 at 06:50:18PM +0200, Enache Adrian wrote: >I have no benchmarks, but judging after the way things are implemented >in the FreeBSD kernel, select() is definitely faster. Can you explain what leads you to make this statement please. >Please someone explain me what is meant in select(2) by: > > If nfds is greater than the number of open files, select() is not guaran- > teed to examine the unused file descriptors. For historical reasons, > select() will always examine the first 256 descriptors. The second sentence appears to be an error. I can't find anything in the current code (or previous versions) that suggests select() would ever examine more than nfd FDs. The only reference to 256 is can find is that FD_SETSIZE used to be 256 and select() used to return EINVAL if nfd > FD_SETSIZE. As for the first sentence, select() should return EBADF if any of the fd_set arguments has a set bit that references an invalid (eg closed) FD. The actual implementation restricts nfd to the highest open FD plus one. To explain further, consider a with FDs 0-60 open. If you pass a fd_set with FDs 0-61 set and nfd = 62, it will scan FDs 0-60 and ignore the bit for FD 61 (ie it will still be set on return). Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message