Further to this, I timed how long it takes to do a poll(2) with a
timeout of 0 (don't wait) for 1021 file descriptors (once again on a
Pentium 100). It took 4.9 ms. Now, in trying to understand the code, I
noticed that even if you call poll(2) with a timeout of 0, the kernel
still manipulates wait queues. I patched the kernel to *not* put the
process on wait queues for 0 timeout, and the time taken went down to
2.9 ms.
Linus, could you please apply this patch?
Regards,
Richard....
diff -urN linux-2.1.51/fs/select.c linux/fs/select.c
--- linux-2.1.51/fs/select.c Tue Jun 17 09:35:59 1997
+++ linux/fs/select.c Sat Aug 23 00:27:25 1997
@@ -423,7 +423,7 @@
wait_table.nr = 0;
wait_table.entry = entry;
- fdcount = do_poll(nfds, fds, &wait_table);
+ fdcount = do_poll(nfds, fds, (timeout == 0) ? NULL : &wait_table);
current->timeout = 0;
free_wait(&wait_table);