Date: Fri, 14 Mar 2003 17:35:16 +1100 From: Peter Jeremy <peterjeremy@optushome.com.au> To: Enache Adrian <enache@rdslink.ro> Cc: David Cuthbert <dacut@kanga.org>, hackers@FreeBSD.ORG Subject: Re: first parameter to select Message-ID: <20030314063516.GA9301@cirb503493.alcatel.com.au> In-Reply-To: <20030313165018.GA703@ratsnest.hole> References: <3E702BCC.3030208@kanga.org> <20030313083710.GA8225@cirb503493.alcatel.com.au> <20030313165018.GA703@ratsnest.hole>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030314063516.GA9301>