RTEMS5 File Descriptors

Ian Caddy ianc at goanna.iinet.net.au
Wed Nov 21 04:21:32 UTC 2018


Hi All,

We are in the process of porting an existing application from RTEMS4.10 
to RTEMS5, and have an issue with "select".

We have previously known of the issue which also exists in RTEMS 4.10, 
but the problem is exacerbated in RTEMS5 due to the change in the way 
the libio descriptors are allocated.

First some history.  With RTEMS and newlib and "select" this only works 
for the first 64 file descriptors as the fd_set size is set in newlib, 
by default to a size of 64.  Therefore you can not use the select call 
is your file descriptor is greater than 64 (on RTEMS 4.10 we got around 
this by creating our own select with our own fd_set), but on RTEMS 5 we 
have also moved to libbsd with a brand new select and underlying 
implementation.

We also open quite a lot of files at particular times, so our 
CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS is set to 500.  These files are 
open at a different time to using the select, and so they lived together OK.

With RTEMS 4.10 the libio would allocate off the list and once freed 
they would be returned to the free list.  The opens would allocate from 
the start of the list, so mostly the fd's were low numbers (under 64).

With RTEMS 5, this has changed so when freed the descriptors are now put 
at the end of the free list, which means we will use all the libio 
allocators before wrapping around into which ever order they were freed 
previously.

This means our select is currently pretty much guaranteed going over the 
default 64 fd_set limit at some stage (currently it is happening right 
at the beginning.... for now on my simple system I have changed our 
MAX_FILE_DESCRIPTORS to 64 and the select is working OK.

Does anyone know of a nice way around this issue without saying don't 
use select.... ;-)

regards,

Ian Caddy




More information about the users mailing list