Re: mmap(), MAP_SHARED, MAP_ANONYMOUS and sharing memory
- From: Rainer Weikusat <rweikusat@xxxxxxxxxxx>
- Date: Mon, 24 Dec 2007 10:44:44 +0100
Bahadir <Bilgehan.Balban@xxxxxxxxx> writes:
I have checked various unix specs and I am puzzled about how to share
memory between two processes using mmap().
AFAIK MAP_ANONYMOUS + MAP_PRIVATE would map /dev/zero (in linux man
pages don't mention /dev/zero) so the process can get some private
zero-initialised free memory, correct?
Before MAP_ANONYMOUS existed, the same effect could be accomplished on
'some operating system' (notably, Solaris) by mmap'ing /dev/zero.
Then what would MAP_ANONYMOUS + MAP_SHARED do?
Create a memory region shared among all processes created by the
process who mmap'ed it and all processes created by these processes
and ...
If Linux specifies no particular file for MAP_ANONYMOUS where would
the shared mapping be found by another process?
Not at all. To share memory among unrelated processing using mmap, one
would either use shm_open or mmap real files.
.
- Follow-Ups:
- Re: mmap(), MAP_SHARED, MAP_ANONYMOUS and sharing memory
- From: Bahadir
- Re: mmap(), MAP_SHARED, MAP_ANONYMOUS and sharing memory
- References:
- mmap(), MAP_SHARED, MAP_ANONYMOUS and sharing memory
- From: Bahadir
- mmap(), MAP_SHARED, MAP_ANONYMOUS and sharing memory
- Prev by Date: Re: check if memory is accessible
- Next by Date: Re: mmap(), MAP_SHARED, MAP_ANONYMOUS and sharing memory
- Previous by thread: mmap(), MAP_SHARED, MAP_ANONYMOUS and sharing memory
- Next by thread: Re: mmap(), MAP_SHARED, MAP_ANONYMOUS and sharing memory
- Index(es):
Relevant Pages
|