lkml.org 
[lkml]   [1997]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: fork: out of memory
Alan Cox wrote:
> The day posix defined the select() interface the dynamic fd concept was
> pretty much broken. Linux 2.0.x has a 256 fd's per process limit and
> there is a kernel patch to raise it. For 2.1.x it is settable on the fly
> but you can never guarantee that if you set it really high you wont break
> some libc routines if you pass them a very high descriptor (thats like
> the Solaris stdio on fd >255 problem). With glibc you can definitely go
> to 4096 and in theory far further.
>
> Alan

Hmm ... FreeBSD gets round this by allowing you to
redefine FD_SETSIZE in your own programs before you
include any header files. The kernel deals with this
automagically in select() by looking at the max fd
you passed and assuming you passed a bitmap large
enough to cope. I've successfully run FreeBSD with
MAX_OPEN (OPEN_MAX?) of nearly 4000 and done a select
with > 256 fd's.

I'm not a FreeBSD advocate, by the way, but this does
seem to be one thing they got right :-)

Rich.

(I quote from /usr/include/sys/types.h)

/*
* Select uses bit masks of file descriptors in longs. These macros
* manipulate such bit fields (the filesystem macros use chars).
* FD_SETSIZE may be defined by the user, but the default here should
* be enough for most uses.
*/
#ifndef FD_SETSIZE
#define FD_SETSIZE 256
#endif

typedef long fd_mask;
#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */

#ifndef howmany
#define howmany(x, y) (((x) + ((y) - 1)) / (y))
#endif

typedef struct fd_set {
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
} fd_set;


--
Richard Jones rjones@imcl.com Tel: +44 171 460 6141 Fax: .. 4461
ABLE INmEDIA Ltd. 262a Fulham Rd. London SW10 9EL. "you'll write in
PGP: www.four11.com telegraphic, or you won't write at all" [Céline]
To send me email, please leave this line in your reply: RJ-AUTH-DHQJENBA

\
 
 \ /
  Last update: 2005-03-22 13:40    [W:0.075 / U:6.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site