From owner-cvs-sys Sun Feb 16 05:32:28 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id FAA04607 for cvs-sys-outgoing; Sun, 16 Feb 1997 05:32:28 -0800 (PST) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id FAA04592; Sun, 16 Feb 1997 05:32:15 -0800 (PST) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.3/8.6.9) id AAA19640; Mon, 17 Feb 1997 00:28:19 +1100 Date: Mon, 17 Feb 1997 00:28:19 +1100 From: Bruce Evans Message-Id: <199702161328.AAA19640@godzilla.zeta.org.au> To: mpp@freefall.freebsd.org, peter@spinner.dialix.com Subject: Re: cvs commit: src/sys/sys types.h Cc: ache@freefall.freebsd.org, bde@zeta.org.au, cvs-all@freefall.freebsd.org, CVS-committers@freefall.freebsd.org, cvs-sys@freefall.freebsd.org Sender: owner-cvs-sys@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >> Sounds like it is time for us to implement the poll system >> call. I noticed that OpenBSD has already done so. > >So have I.. But then again, you're all probably sick of hearing >that by now :-] How much slower would it be? :-) >Also, aren't you misreading the roundup? > > /* The amount of space we need to allocate */ > ni = howmany(roundup2 (uap->nd, FD_SETSIZE), NFDBITS) * > sizeof(fd_mask); > if (ni > p->p_selbits_size) { > /* realloc p_selbits */ > } > ...later... > /* The amount of space we need to copyin/copyout */ > ni = howmany(uap->nd, NFDBITS) * sizeof(fd_mask); Oops. I had forgotten that select() doesn't actually initialize the entire descriptor set like its man page says. It only zeros a convenient number of bits above `nfds'. We considered only rounding to a byte boundary but decided to be bug for bug compatible. The first `ni' seems to be left over from a version that wanted to round to an fd_set boundary. It doesn't hurt to allocate a few extra bits, but bzeroing them is just wasteful. >Note the reuse of 'ni'. The application is only exposed to sizeof(fd_mask) >(fd_mask == unsigned long) rounding, not FD_SETSIZE. The FD_SETSIZE >rounding is only to size the initial workspace to save excess reallocation >calls to the kernel allocator. Even then it expands by 32 bytes (256 >bits), not FD_SETSIZE. Yes, the change for user space was OK except for performance problems. Sorry for the false alarm. >Also, it seems to me that the code is not very optimal. I'm probably >about to embarress myself here, but wouldn't it be better something like >this?: >... It should just clear 6 * (minimum (rounded) number of bits) and not use the bits at the end. Bruce