Date: Mon, 9 Dec 1996 19:56:16 -0500 (EST) From: "Marc G. Fournier" <scrappy@hub.org> To: hackers@freebsd.org Subject: Multiple Buffer allocation of Shared Memory Message-ID: <Pine.NEB.3.95.961209194502.12999J-100000@hub.org>
next in thread | raw e-mail | index | archive | help
Hi... Just starting to play with shared memory, and have hit a wall that I don't know if its too be expected, or if I've screwed something up... Basically, I'm setting up the shared memory as: ---- int shmid[MAXBUF]; /* shared memory pointers */ Mesg *mesgptr[MAXBUF]; /* data cells */ for(ii = 0; ii < MAXBUF; ii++) { if((shmid[ii] = shmget(SHMKEY + ii, sizeof(Mesg), PERMS | IPC_CREAT)) < 0) { fprintf(stderr, "cannot initialize shared memory buffer #%d\n", ii); exit(-1); } if((mesgptr[ii] = (Mesg *)shmat(shmid[ii], (char *)0, 0)) == (Mesg *)-1) { printf("%s\n", strerror(errno)); fprintf(stderr, "cannot attach shared mem segment #%d\n", ii); exit(-1); } } ---- Where MAXBUf == 100, and Mesg is: ---- #define MAXMESGDATA 2048 typedef struct { int mesg_len; char mesg_data[MAXMESGDATA]; } Mesg; ---- The problem seems to be when 'ii == 8', the shmget() is working, but the shmat() is failing with 'strerror()' returning with: ---- hub> ./client Too many open files cannot initialize mesgptr #8 ---- I've tried doing an 'unlimit' before running, same results... I don't know enough about shared memory yet, but figure that I should be able to get further then allocating ~20k for shared memory, no? Without anything special needed in the kernel config? I would have assumed that if I had screwed up my syntax, it would be failing at ii == 0, which it isn't. limit shows: descriptors 1064 which is the only one that I would think is appropriate to the situation...unless its a kernel config problem... As I'm pretty much using the example straight out of "Unix Network Programming", pg 165...if anyone can point out the error of my ways, it would be much appreciated... Thanks in advance... Marc G. Fournier scrappy@hub.org Systems Administrator @ hub.org scrappy@freebsd.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.95.961209194502.12999J-100000>