[comp.sys.sun] Shared Memory...

richard%aiai.edinburgh.ac.uk@nss.cs.ucl.ac.uk (Richard Tobin) (04/21/89)

I have a program that uses the shm* routines to allocate memory that will
be shared between a process and its children.  It needs an unshared area,
a shared area, and another unshared area.  The precise addresses don't
matter (though they mustn't be too far apart) but the ordering does.

Under release 3 I just used sbrk(), shmat() and sbrk() again, but under
release 4 this puts the shared segment at a much higher address than the
other segments.  If I tell shmat() to put it just after the break, the
second sbrk() fails.

What's the best way round this?  (Answers like "change your program so
that the order doesn't matter" won't help.)  Must I use mmap()?  If so, do
I actually have to specify a file somewhere to correspond with the mapped
area?  And if so, will it use real disk space?

-- Richard

adp@ksg.cs.reading.ac.uk (Andrew Pollard) (06/05/91)

Hello,

 I am trying to share a *large* array between processes (about 3-4 Meg), so
consequently I have had to split it into a number of 1 Meg chunks. What I
planned to do was to use the shmat call to map in each segment into memory so
as it appeared as one large array... although I keep on getting illegal
address errors. What I would like to know is, is there any way of asking SunOS
for a range of addresses that shmat will accept? ie "Tell me where I can fit
xxx bytes into memory".

Thanks,
 Andrew

PS. I don't know where this message will end up, so please reply via email.