Subject: Re: mapping shared memory at a fixed address
To: Rahul Kulkarni <crypto_rahul@yahoo.com>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 02/07/2005 10:39:18
--g7w8+K/95kPelPD2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Fri, Feb 04, 2005 at 04:05:25PM -0800, Rahul Kulkarni wrote:
> Wondering if anyone can give some pointers on how to
> make mmap map a shared memory segment at a specified
> address always, in different address spaces. MAP_FIXED
> with a specified address works but is not gauranteed.
> In other words, how can I "reserve" the same virtual
> address in different address spaces to map to the same
> segment..=20
You can't.
Why do you need to?
The problem is that if something else already is mapped at the address you=
=20
want, the new mmap won't work. The only way you could get around that was=
=20
if you mapped the area and then had the process fork into a lot of=20
children. However the children could not exec..
If you want to store (or pass) pointers to things in the area, just store=
=20
or pass relative pointers. Pass (intptr_t)ThePointer -=20
(intptr_t)MapAddress. Then in the recipient just add the stored or passed=
=20
integer to the local map address.
Take care,
Bill
--g7w8+K/95kPelPD2
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)
iD8DBQFCB7XWWz+3JHUci9cRAoadAJ4jid8tLi8kVUM1N/PmpSlgSfo6+QCffc83
p4l0WNr/0KM/jFOuFadk/HY=
=ObQu
-----END PGP SIGNATURE-----
--g7w8+K/95kPelPD2--