shared memory

Moellers josef at nixpbe.UUCP
Mon Sep 24 16:33:21 AEST 1990


In <566 at gestetner.oz> andrew at gestetner.oz (Andrew Hunt) writes:

>I am having problems with UNIX shared memory system functions
>(shmget, shmctl, shmop) - our system is SUN O/S 4.0.x.  
>I am trying to attach some data to a shared memory identifier.

>	assign global_start_address
>	assign global_size

>	global_shmid = shmget(IPC_PRIVATE,global_size,0777|IPC_CREAT);

>	shmat(global_shmid,global_start_address,SHM_RDONLY);

>The shmget is always successful but the shmat fails.  I have tried 
>to assign the global_start_address to many different sizes and 
>addresses.  The addresses I have tried have been from malloc'ed memory,
>stack space, initialised data space, uninitialised data space....
>I have experimented with changing permissions and have changed most of
>the parameters but the only thing that has worked is to set

>	global_start_address = (char *)0;

>which allow the system to find some space for me.

>Does anyone know what areas of memory can be legally attached to 
>shared memory?

The system will ALLWAYS find space for You. It's YOUR task to tell it
			     ^^^^^
where to put it.
^^^^^
The address where to put it ("global_start_address") must not result in
part or all of the shared memory segment overlaying part or all of Your
allocated virtual address space.
So:
	break <= global_start_address < SP - global_size
Try something like global_start_address = 0x80000000, which, on a 32 bit
system, should put the shared memory segment in the middle of Your 4GB
virtual address space.

--
| Josef Moellers		|	c/o Nixdorf Computer AG	|
|  USA: mollers.pad at nixdorf.com	|	Abt. PXD-S14		|
| !USA: mollers.pad at nixdorf.de	|	Heinz-Nixdorf-Ring	|
| Phone: (+49) 5251 104662	|	D-4790 Paderborn	|



More information about the Comp.unix.programmer mailing list