Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Feb 1997 00:28:19 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        mpp@freefall.freebsd.org, peter@spinner.dialix.com
Cc:        ache@freefall.freebsd.org, bde@zeta.org.au, cvs-all@freefall.freebsd.org, CVS-committers@freefall.freebsd.org, cvs-sys@freefall.freebsd.org
Subject:   Re: cvs commit: src/sys/sys types.h
Message-ID:  <199702161328.AAA19640@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702161328.AAA19640>