[En-Nut-Discussion] select() implementation / Re-Integration of the "devnut_select" branch
ole.reinhardt at embedded-it.de
Fri Sep 13 16:24:56 CEST 2013
quite some time ago I started implementation of the posix select()
function for Nut/OS. The results can be found in the devnut_select
branch and perhaps some of you just took a look onto the new code.
select() can be used for asynchronous communication on several devices
(file descriptors) or sockets at the same time without blocking waiting
for read or write operations.
Until now, Nut/OS did not support waiting for data on several file
descriptors at the same time. You could either wait blocking for an I/O
operation or you had to wait (busy) using non-blocking mode.
In the latter, you had to manually retry a read() or write() operation
until it succeeded.
select() introduces a new option, where you can sleep with your thread
until a defined event happens on one filedescriptor out of a set of
observed file descriptors.
This way you can easily read from two UARTs at the same time in the same
thread without the need of looping in non-blocking mode, until some data
has been received.
Further you can also easily implement a TCP/IP server which can handle
several requests (sockets) at the same time without the need to create
an own thread for each connection.
select() will help you to save a lot of resources, a you can live with
less threads and do not need to do busy looping.
- It is working at least with most UART drivers
- Socket support still needs to be added
- Support for further kinds of character devices can be easily added,
support for real files (on a filesystem) has not yet been thought
Unfortunately the implementation of select() required some fundamental
changes in the way file descriptors where implemented. If you are
interested in details, please let me know and I'll explain this in a
As mentioned above, the select() call is not yet implemented for all
devices and not yet supported by sockets, but I'm currently working on
the socket support and hope to have this finished very soon.
I'd like to re-integrate the development branch into the trunk soon, but
like to get your OK before doing so. The changes are quite fundamental
in some places, and there is at least a little risk to break existing
code. Therefor I'd like to get your OK first, before starting the
kernel concepts GmbH Tel: +49-271-771091-14
Sieghuetter Hauptweg 48 Mob: +49-177-7420433
More information about the En-Nut-Discussion