Re: Maximum file descriptor number in select()?

2023-02-18 Thread Gregory Nutt
> >..l. I could not find where > > select() or poll() are implemented in the nuttx repository. Is there > some > > kind of magic going on with that? > > > > > They hare here: > https://github.com/apache/nuttx/blob/master/fs/vfs/fs_select.c > https://github.com/apache/nuttx/blob/master/fs/vfs/fs_p

Re: Maximum file descriptor number in select()?

2023-02-18 Thread Xiang Xiao
On Sun, Feb 19, 2023 at 10:21 AM Gregory Nutt wrote: > > fd_set is a 32bit array, the max fd number is hardcode to 256: > >https://github.com/apache/nuttx/blob/master/include/sys/select.h#L38-L91 > > > I just found that a

Re: Maximum file descriptor number in select()?

2023-02-18 Thread Gregory Nutt
> fd_set is a 32bit array, the max fd number is hardcode to 256: >https://github.com/apache/nuttx/blob/master/include/sys/select.h#L38-L91 I just found that and was sending an email. I could not find where select() or pol

Re: Maximum file descriptor number in select()?

2023-02-18 Thread Xiang Xiao
fd_set is a 32bit array, the max fd number is hardcode to 256: https://github.com/apache/nuttx/blob/master/include/sys/select.h#L38-L91 it's better to define FD_SETSIZE to OPEN_MAX. On Sun, Feb 19, 2023 at 9:53 AM Gregory Nutt wrote: > That is okay. My answer is possibly wrong anyway. OPEN_MA

Re: Maximum file descriptor number in select()?

2023-02-18 Thread Gregory Nutt
That is okay. My answer is possibly wrong anyway. OPEN_MAX is the maximum number of open files. For the select, the file descriptor set was held in a 32-bit bit set so the maximum was 31. But that logic has been redesigned and I don’t know how it works now. Hopefully, it supports up to OPEN_

Re: Maximum file descriptor number in select()?

2023-02-18 Thread KIKUCHI Takeyoshi
Hi Greg, Sorry, it seems that the same one was delivered late, probably because I sent it with the wrong email source account (not the one I subscribed to the list). best regards, KIKUCHI Takeyoshi On 2023/02/19 9:20, Gregory Nutt wrote: The maximum number of file descriptors is a constant

Re: Maximum file descriptor number in select()?

2023-02-18 Thread Gregory Nutt
The maximum number of file descriptors is a constant value provided by the preprocessor definition OPEN_MAX. On 2/16/2023 5:44 PM, KIKUCHI Takeyoshi wrote: currently porting the Nim language to NuttX. (It has been merged into the Nim devel branch) When using select/epoll, it is necessary to de

Maximum file descriptor number in select()?

2023-02-18 Thread KIKUCHI Takeyoshi
currently porting the Nim language to NuttX. (It has been merged into the Nim devel branch) When using select/epoll, it is necessary to determine the maximum value of file descriptor in order to assign a structure to store the fd to be waited in advance. It is used in this way. - pro

Re: Maximum file descriptor number in select()?

2023-02-16 Thread Gregory Nutt
Other POSIX-based systems use getrlimit(RLIMIT_NOFILE) to derive maxDescriptor. ulimit(4, nn) should also work but is old and obsolete (/like me ;)/ ). https://man7.org/linux/man-pages/man3/ulimit.3.html In terms of "POSIX compliant", the same system calls could be used for a clean impleme

Re: Maximum file descriptor number in select()?

2023-02-16 Thread KIKUCHI Takeyoshi
Hi Alan, Greg. Thanks for the advice. Other POSIX-based systems use getrlimit(RLIMIT_NOFILE) to derive maxDescriptor. ## Returns the maximum number of active file descriptors for the current ## process. This involves a system call. For now `maxDescriptors` is ## suppo

Re: Maximum file descriptor number in select()?

2023-02-16 Thread Gregory Nutt
In NuttX, the current number of file descriptions is held in the fl_rows field of struct filelist.  Access to that field is provided only through the /proc file file system. Hmm.. the test is   if (row * CONFIG_NFILE_DESCRIPTORS_PER_BLOCK > OPEN_MAX)     {   return -EMFILE;     } So th

Re: Maximum file descriptor number in select()?

2023-02-16 Thread Gregory Nutt
Since the available memory capacity varies from device to device, Is there any way to find the best value for each build config? The maximum number of file descriptors for a task is OPEN_MAX which is determined by CONFIG_LIBC_OPEN_MAX.  The actual number may vary from task to task. In Lin

Re: Maximum file descriptor number in select()?

2023-02-16 Thread Alan C. Assis
Hi Kikichi-san, In the past NuttX used to have a config to define the max number of file descriptors/file streams. Now it is allocated dynamically. I think the max number of FDs should be board and application dependent. So, maybe in this case is better to start with a smaller "reasonable" amoun

Maximum file descriptor number in select()?

2023-02-16 Thread KIKUCHI Takeyoshi
currently porting the Nim language to NuttX. (It has been merged into the Nim devel branch) When using select/epoll, it is necessary to determine the maximum value of file descriptor in order to assign a structure to store the fd to be waited in advance. It is used in this way. - pro