Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Poll Support for I/O
Adds a new compile-time configurable option to use poll/ppoll as the select
mechanism.
This allows the system to use more than 1024 file descriptors.
Implementation Notes
The poll state is maintained in __device_select_state_struct, which has
been augmented to include a pollfd array and count for the i/o selection.
The size of the array is configurable with MAX_POLLFDS, which matches
MAX_CONDVARS unless explicitly defined.
The state also has 2 bitmaps for read and write ready fds, which behave
similar to fd_set used in select -- but their size is not hard-limited
to 1024 fds as in select. Instead, it matches the configured size of the
pollfd array.
The actual poll is implemented in __device_select.
On entry, the ready sets and fd count are cleared in the state.
File descriptors are added in ___device_select_add_fd, which for poll
pushes the file descriptor to the poll set and increments the count.
When the poll completes, the poll set is scanned updating the bitmaps for
the ready file descriptors.
Using a bitmap for marking the ready sets allows the existing device_select
code to work with minimal modifications, without incurring performance
penalty in the rediness checks.
The checks are implemented using __FD_ISSET, which has the same
interface for both select and poll.
When select is used, the macro is defined to FD_ISSET.
When poll is usde, the macro is defined to operate on a poll bitmap.
If the system has ppoll available (GNU/Linux), then ppoll will be used
instead of plain poll, allowing high resolution timeouts.
Configuration Options
A new configure option has been added to enable poll as the select mechanism:
--enable-poll
The maximum number of file descriptors in the poll set is controlled by
the MAX_POLLFDS parameter.
By default it matches MAX_CONDVARS (8192).
If you want to use more file descriptors, configure with
CFLAGS="-DMAX_POLLFDS=XXX"
Using poll