Re: What's wrong with MAP_SHARED|MAP_ANONYMOUS?

Andi Kleen (ak@muc.de)
27 Sep 1998 14:40:44 +0200


paul@dawa.demon.co.uk (Paul Flinders) writes:

> "David S. Miller" <davem@dm.cobaltmicro.com> writes:
>
> > Date: Sun, 27 Sep 1998 03:49:04 +0200
> > From: Felix von Leitner <leitner@math.fu-berlin.de>
> >
> > I always get EINVAL :(
> >
> > Shared anon pages are not supported. You can get similar
> > functionality from sysv ipc shared memory.
>
> 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.

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

-Andi

-
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/