shared memory

Andrew Hunt andrew at gestetner.oz
Fri Sep 21 12:05:24 AEST 1990


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?

Thanks,
	Andrew Hunt

PS: if it helps we are trying to set up the global data space of
several UNIX processes to use common memory so that we can simulate
the shared memory of an imbedded controller.



More information about the Comp.unix.programmer mailing list