I'm getting confused with all the back and forth in this thread, so take
this message to be a "state of the problem" question.
As far as I can tell, these are the questions:
1) How large a chunk of shared memory can...
a) two threads in a process allocate
b) two separate processes allocate (when it's IPC_PRIVATE)
c) two processes allocate, where they can both see it.
2) Under what conditions do these memory allocations...
a) fail to occur
b) fail to be free'd on program crash (possibly needing root to free
them)
c) cause the machine to crash
d) cause unacceptable swapping
Alan has tested 1.c (the case of most interest) and it worked for him. I
tested the code he posted, modified to sleep 15 seconds before exiting to
make it easy to run 2 copies, and it worked for me too (Dual PII 350's,
kernel 2.2.8). ie.
$ echo "700000000" >/proc/sys/kernel/shmmax
$ gcc test.c
$ ./a.out &; ./a.out &
OK, shm_game = 2697
OK, shm_game = 2698
OK, shm_game = 2697
OK, shm_game = 2698
So as far as I can tell the IPC_PRIVATE problem is somehow isolated to
Vincent's machine, and the SHMMAX issue is a problem of obscure (and
possibly wrong?) default values which are setable at run time.
The 2.abcd series of problems seem to not have been duplicated on anyone
elses machine, correct? Are there any suggestions for things we could try
to get them duplicated?
For completeness, here's my changes to the test program:
/* test.c */
#include <stdio.h>
#include <sys/ipc.h>
#include <sys/shm.h>
static void alloc_one(char c)
{
int shm_game;
int *partij;
shm_game = shmget(ftok(".",c),150000000,IPC_CREAT|0777);
partij = (int *)shmat(shm_game,0,0);
if( partij == (int *)-1 )
{
perror("Error allocating Game");
exit(1);
}
printf("OK, shm_game = %i\n", shm_game);
}
int main(int argc, char *argv[])
{
alloc_one('a');
alloc_one('b');
sleep (15);
exit(0);
}
/* end test.c */
respectfully,
-emile
-------------------------------------------------------------------
ESR: I want to live in a world where software doesn't suck.
RMS: Any software that isn't free sucks.
Linus: I'm interested in free beer.
- As reported by Elizabeth O. Coolbaugh of LWN
from LinuxWorld Conference and Expo
-------------------------------------------------------------------
-
Linux SMP list: FIRST see FAQ at http://www.irisa.fr/prive/mentre/smp-faq/
To Unsubscribe: send "unsubscribe linux-smp" to [EMAIL PROTECTED]