sharing memory map between processes (same parent)



I have forked two processes from the same parent. I'd like to have one of them
do open() and mmap() to map a file into memory (madvise would also be used).
Then I would like the other process to be able to access that mapping. Is
there a way to get that mapping shared with another process (much like it
would be had the parent mapped it first then forked the two child processes)
or at least transfer the mapping from one process to another? Note that it
will not necessarily be a mapping of the entire file, and the first process
may be keeping the descriptor open for later mapping of another part of the
file. Also, it may be possible to make it so the first process never does
any access of the mapped pages.

--
|WARNING: Due to extreme spam, I no longer see any articles originating from |
| Google Groups. If you want your postings to be seen by more readers |
| you will need to find a different place to post on Usenet. |
| Phil Howard KA9WGN (email for humans: first name in lower case at ipal.net) |
.



Relevant Pages

  • Re: [PATCH 0/3] Guarantee faults for processes that call mmap(MAP_PRIVATE) on hugetlbfs v2
    ... This guarantees all future faults against the mapping will succeed. ... The first patch of the set is purely mechanical code move to ... as long as the child keeps ... the parent is no longer guaranteed to be reliable. ...
    (Linux-Kernel)
  • Re: [PATCH] MM: use DIV_ROUND_UP() in mm/memory.c
    ... tree 8037adc04b57cd6150456399b7caccf99489385a ... parent bf0bd376f79cadb4f8cd454db1723eb9be0aabc1 ... struct zap_details details; ...
    (Linux-Kernel)
  • Re: sharing memory map between processes (same parent)
    ... do openand mmap() to map a file into memory (madvise would also be used). ... Then I would like the other process to be able to access that mapping. ... it may be possible to make it so the first process never does ...
    (comp.unix.programmer)
  • Re: sharing memory map between processes (same parent)
    ... |> I have forked two processes from the same parent. ... |> Then I would like the other process to be able to access that mapping. ... it may be possible to make it so the first process never does ... | Why not just have both processes mmap() the same file? ...
    (comp.unix.programmer)
  • Re: sharing memory map between processes (same parent)
    ... |> I have forked two processes from the same parent. ... |> Then I would like the other process to be able to access that mapping. ... it may be possible to make it so the first process never does ... | You have a habit of posting suggested solutions rather than problems. ...
    (comp.unix.programmer)