Re: Timings for optimised poll(2)

Werner Almesberger (almesber@lrc.di.epfl.ch)
Mon, 25 Aug 1997 12:46:54 +0200 (MET DST)


Richard Gooch wrote:
> Now, if you think a little more about what select(2) does, you will
> note that you have to set up the fd_sets before you call it, *each and
> every time*, because the fd_sets are modified by the call. So, to set
> up the fd_sets, you have to do a "naive" scan through the
> list. Clever.

I'd set up the set(s) once and copy them from then on, possibly adding
or deleting bits as FDs are created/closed. Last time I checked, memcpy
was reasonably fast ...

Rogier Wolff wrote:
> If you want to be "portable" across different limits, use
> fd = fopen ("/proc/kernel/file-max","r");

Very nice. So you get one extra #ifdef linux or such, plus something
like file-max bits that will always be zero but you're scanning them
anyway (assuming fds_in_use << file-max). I'd calculate the maximum FD
number and use that (plus a bit more if allocating dynamic memory, so
that I don't have to realloc for each new FD). Redo the operation after
closing a lot of FDs.

- Werner

-- 
  _________________________________________________________________________
 / Werner Almesberger, DI-LRC,EPFL,CH   werner.almesberger@lrc.di.epfl.ch /
/_IN_R_133__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/