You can enable extended (64K) file descriptors in DIGITAL UNIX Version 4.0D, as described in Section 1.10, by following these steps:
setsysinfo()
system call to 1. When
SSI_FD_NEWMAX
is set to 1, the process
utask
bit is turned on and the process's hard file limit is raised to 64K.
This setting is inherited by child processes.
setrlimit()
call:
#include <sys/resource.h>
struct rlimit *rlp;
rlp->rlim_cur = 6000; rlp->rlim_max = 6000; setrlimit(RLIMIT_NOFILE, rlp);
This setting is inherited by child processes. See the
setrlimit()
reference page for details.
select()
,
fd_set
,
FD_CLR
,
FD_ISSET
,
FD_SET
,
or
FD_ZERO
.
Choose one of the following:
<sys/select.h>
by specifying the new maximum (65536). You must do this before
including the
<sys/time.h>
header file, which includes
<sys/select.h>
:
#define FD_SETSIZE 65536 #include <sys/time.h>
This setting is not inherited by child processes; therefore,
FD_SETSIZE
must be set explicitly in the code of a child process that requires
64k file descriptor support.
fd_set
structures, use
fd_set
pointers in conjunction with a
malloc
function to provide forward compatibility with any future changes to
the maximum file descriptor limit:
fd_set *fdp;
fdp = (fd_set *) malloc( (fds_howmany(max_fds,FD_NFDBITS))*sizeof(fd_mask));
The
max_fds
would be the number of file descriptors to be manipulated. The soft
file descriptor limit is a good choice. All other keywords are
defined in the
select.h
header file:
#include <sys/time.h> #include <sys/resource.h>
my_program() { fd_set *fdp; struct rlimit rlim; int max_fds;
getrlimit(RLIMIT_NOFILE, &rlim); max_fds = rlim.rlim_cur;
fdp = (fd_set *) malloc( (fds_howmany(max_fds,FD_NFDBITS))*sizeof(fd_mask));
FD_SET(2, fdp);
for (;;) { switch(select(max_fds, (fd_set *)0, fdp, (fd_set *)0, struct timeval *)0)) { ... }
System administrators should note that
max-vnodes
must be set high enough for the needs of any application that requires
a high number of descriptors. The
max-vnodes
is the number of in-memory structures for files, and is usually set by
default to 5% of system memory. A rough guide is 1 vnode per
descriptor. For more information about this setting, see the
System Administration
and
System Configuration and Tuning
guides.
To disable support for up to 64K file descriptors once the previous
procedure has been carried out, set the
SSI_FD_NEWMAX
option of the
setsysinfo()
system call to 0. When
SSI_FD_NEWMAX
is set to 0, the process
utask
bit is turned off and the process's
hard file limit returns to the default maximum of 4K, unless the
process is using more than 4K file descriptors. In that case, the
setsysinfo()
call returns an error,
EINVAL
.
Additionally, if a calling process's file descriptor hard or soft
limit exceeds 4K, it is set to 4K. This setting can be inherited by
child processes.