[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [microblaze-uclinux] select() with fd > 31



Also, if I modify my code to this:

#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]);
   }
#if 0
   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);
#endif
   printf ("\n\nselecting on fd 32\n");
   FD_ZERO(&rdset);
   FD_SET(32, &rdset);
   numready = select (33, &rdset, 0, 0, 0);
printf ("numready = %d\n", numready); return 0;
}

It will hang forever on the select:

# ./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

selecting on fd 32

-----------------------
It will hang if I select on 32, 33, 34, or 35. Selecting on <=31 and >=36 works. As I said, I can avoid this for now. If it kills me again I'll try the printk debugging.

Thanks,
Jim



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/