Re: sharing memory map between processes (same parent)



On Mon, 28 Apr 2008 07:37:57 -0700 (PDT) David Schwartz <davids@xxxxxxxxxxxxx> wrote:
| On Apr 27, 1:04 pm, phil-news-nos...@xxxxxxxx wrote:
|
|> 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.
|
| What's your outer problem? Why not just have the other process create
| the mapping itself? The answer to your question would be very
| different if the reason was that the mapping was private than it would
| be if the problem was that the mapping contains pointers and needs to
| be at the same address for all processes.

The idea is to have some of the work spread out between processes and avoid
having to use threads (because I don't want to share the whole VM). There
is a way to transfer (already open) file descriptors between processes. I
was hoping there might be a similar way to transfer already mapped pages
between processes. But if there is not, I will just have to do things some
other way.


| You have a habit of posting suggested solutions rather than problems.

You have a habit of being accusatory. But I've only noticed this over the
past couple years. I remember long ago your postings were more civil.

--
|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)
    ... |> 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)
  • sharing memory map between processes (same parent)
    ... I have forked two processes from the same parent. ... do openand mmapto 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)
    ... 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)