[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] select() with fd > 31
I wrote a test to illustrate my problem. Select above 31 actually works
in this test, but the results are still unexpected:
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int fds[35];
int i;
fd_set rdset;
int maxfd = 0;
int numready;
int actual_ready;
FD_ZERO (&rdset);
for (i = 0; i < 35; i++) {
printf ("opening ");
fds[i] = open ("select_test", O_RDONLY);
if (fds[i] < 0) {
printf ("open error in index %d", i);
exit (1);
}
if (fds[i] > maxfd) maxfd = fds[i];
FD_SET (fds[i], &rdset);
printf ("%d ", fds[i]);
}
printf ("\n");
printf ("maxfd = %d\n", maxfd);
numready = select (maxfd+1, &rdset, 0, 0, 0);
printf ("numready = %d: ", numready);
actual_ready = 0;
for (i = 0; i < 35; i++) {
if (FD_ISSET (fds[i], &rdset)) {
printf ("%d ", fds[i]);
actual_ready++;
}
}
printf ("\n");
printf ("actual ready = %d\n", actual_ready);
printf ("selecting on fd %d\n", fds[34]);
FD_ZERO(&rdset);
FD_SET(fds[34], &rdset);
numready = select (maxfd+1, &rdset, 0, 0, 0);
printf ("numready = %d\n", numready);
return 0;
}
Results are:
# ./select_test
opening 4 opening 5 opening 6 opening 7 opening 8 opening 9 opening 10 opening 11 opening 12 opening 13 opening 14 opening 15 opening 16 opening 17 opening 18 opening 19 opening 20 opening 21 opening 22 opening 23 opening 24 opening 25 opening 26 opening 27 opening 28 opening 29 opening 30 opening 31 opening 32 opening 33 opening 34 opening 35 opening 36 opening 37 opening 38
maxfd = 38
numready = 28: 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 36 37 38
actual ready = 31
selecting on fd 38
numready = 1
I was expecting numready = actualready = 35. Notice that fds 32-35
don't show up.
I found a way around this (or just avoid it) for now so it's no longer
critical.
John Williams wrote:
Hi Jim,
Jim Van Vorst wrote:
I have run into a problem with select(). It won't set bits for file
descriptors > 31. I.e. it looks like there's a 32-bit limitation
down in the bowels somewhere. I am using the normal FD_SET, FD_ISSET
macros to set and check my fd bits. I know I am setting the right
bits, and I know there's data waiting, but bits above 31 are never
set on the return from select().
I am running linux 2.6.
Anyone seen this before? Is this a uclinux thing? A microblaze
thing? Am I delusional?
Are you still having trouble with this (I've been on holdidays)
Checking the obvious - you are passing *pointers* to the fd_sets in
question right, not the structures themselevs?
Are you correctly setting the 'n' parameter to select(), to be max(fd)
+ 1 as per "man select"?
It's worth peppering some printk's in linux-2.6/fs/select.c, in the
core_sys_select() function, to find out what's going on. This is all
mainline code, no microblaze or uclinux specific limitations I'm aware
of. You should be able to specify up to 1024 FDs.
Cheers,
John
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive :
http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/