Memory sharing question

From: Stephen Dolan
Date: Sat Feb 24 2007 - 06:50:30 EST


Hi.

I'd like to know if it is possible to get two processes to share a
memory segment at the same address, e.g. both mmap() the same file and
have it return the same address in both.

This could be done by mmap()ing it in one of them, communicating the
address to the other (via a socket or whatever), which then mmap()s it
with the address as the "start" parameter and MAP_FIXED. However, that
tends to fail, and MAP_FIXED can have annoying side-effects (killing
off other mappings).

Is it possible to reliably make the same address in two different
processes point to the same bit of physical memory?

The point of all this is that I want to pass a large, complex (full of
pointers) data structure to a different process, and I don't want the
overhead of serialising it down a socket and then parsing it at the
other end (the data structure's pretty big, and the other process
won't need it all). Is this possible?

Thanks,
Stephen Dolan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/