Subject: Re: mapping shared memory at a fixed address
To: Wolfgang Solfrank <ws@tools.de>
From: Rahul Kulkarni <crypto_rahul@yahoo.com>
List: netbsd-users
Date: 02/08/2005 11:56:19
The objective is for multiple proocesses to map a
shared memory segment at the same fixed virtual
address. What I'm trying to achieve is basically a
parent process creates a shared memory segment using
mmap and maps it at some location say abcd. It then
forks and execs bunch of child processes which need to
map the same shared memory segment at the same
location abcd. The reson is due to shared pointers in
the shared memory ( I agree we can do relative
pointers, but in this paritcular case I'm not looking
to do that because of some other constraints). Its not
just one process trying to map at a given location,
its is a bunch of processes which need to map at the
same location.What are the other options here for me? 
1. A linker script which can add a zero filled region
to all the executables at a given address range?
2. Reserving a range (how?) between the data and the
stack limit for all the processes? 

thanks, Rahul

--- Wolfgang Solfrank <ws@tools.de> wrote:

> Hi,
> 
> Sorry for churning in this late, but:
> 
> Bill Studenmund wrote:
> > On Tue, Feb 08, 2005 at 11:51:10AM -0500, Stephan
> Uphoff wrote:
> > 
> >>On Mon, 2005-02-07 at 13:39, Bill Studenmund
> wrote:
> >>
> >>>On Fri, Feb 04, 2005 at 04:05:25PM -0800, Rahul
> Kulkarni wrote:
> >>>The problem is that if something else already is
> mapped at the address you 
> >>>want, the new mmap won't work. The only way you
> could get around that was 
> >>>if you mapped the area and then had the process
> fork into a lot of 
> >>>children. However the children could not exec..
> >>
> >>Mhhh .. maybe adding a zero filled section to the
> executable(s) at a
> >>fixed address would work.
> >>The executable could then unmap / remap the
> reserved address range.
> >>If this would work it probably needs a linker
> script from hell ;-).
> > 
> > 
> > The problem is that you'd have to have that linker
> script link everything 
> > around the hole.
> 
> I'm not sure what you are trying to achieve here,
> but mmap will work quite
> happily mapping over some area that is already
> occupied by something else.
> Of course there will be problems when you mmap over
> an area that is used
> for something viable (like e.g. libc), so probably
> you are trying to avoid
> this by this linker script dance.  However, there
> are other ways to guarrantee
> that some address space isn't used (like e.g. static
> linking and mmaping
> somewhere between data limit and stack limit).
> 
> Ciao,
> Wolfgang
> -- 
> ws@TooLs.DE                            Wolfgang
> Solfrank, TooLs GmbH
> 



		
__________________________________ 
Do you Yahoo!? 
All your favorites on one personal page – Try My Yahoo!
http://my.yahoo.com