Re: What's wrong with MAP_SHARED|MAP_ANONYMOUS?

Felix von Leitner (leitner@math.fu-berlin.de)
Mon, 28 Sep 1998 20:24:57 +0200


Thus spake Andi Kleen (ak@muc.de):
> > Would it work if you create a scratch file, open it, unlink it, fill it
> > to the right size with zeros and then map it with a shared mapping?
> Yes, but you don't even need to fill it with zeros. Just use
> ftruncate(fd, length). This has the advantage that unused blocks won't
> be allocated.

What is the problem with the shared anonymous mmap syntax?
I mean, if the programmer is so dumb that he does not use blocks he
allocated, God help him. That should not be a reason not to have a
library call.

The best idea would probably be to add this syntax to libc. There are
programs that use this.

> These mappings have a big advantage over anonymous mappings too - you
> can pass them around between processes using fd descriptor passing.

Good point. On the other hand, documentation on fd passing is quite
sparse, isn't it? Does anyone have demo code that works on the
important platforms where fd passing is supported?

Felix

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/