Re: sharing memory map between processes (same parent)



On Sun, 27 Apr 2008 21:00:12 -0400 Barry Margolin <barmar@xxxxxxxxxxxx> wrote:
| In article <fv2m7o01es1@xxxxxxxxxxxxxxxxx>, phil-news-nospam@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.
|
| I don't know of any way to transfer a mapping. Processes don't
| generally have the ability to change anything about other properties,
| other than through low-level manipulation like ptrace().
|
| Why not just have both processes mmap() the same file?

The other process will be busy at the time. I was hoping for something that
was similar to being able to transfer an open file descriptor.

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

  • 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)
  • 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)
  • 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. ... | what to map at runtime, there no way for process A to map shared ... | As Barry said the only way is to continue using mmap and maybe provide ...
    (comp.unix.programmer)
  • [PATCH, RFD] Unbreaking nommu mmap, v2
    ... A while ago I sent out a patch to change mmap behaviour on nommu targets. ... Currently, the kernel requires a munmap call for every mmap, with the exact same address range; this is inconsistent with behaviour on mmu systems, and complicates the malloc implementation in uClibc. ... Every VMA can be in two states: either it manages a power-of-2 sized compound ... mapping we're capable of supporting ...
    (Linux-Kernel)