Re: Shared memory IPC using NIO memory-mapped files -- anyone done this?

Randall R Schulz <[email protected]>
Newsgroups gmane.comp.windows.devel.java.advanced
Message-ID <[email protected]>
On Saturday 18 August 2007 09:59, Bob Lee wrote:
> On 8/18/07, Randall R Schulz <[email protected]> wrote:
> > In any decent operating system, memory-mapped file pages are kept
> > in core as much as other concurrent file access and RAM demand
> > allows. Assuming one's (system-wide) working set does not exceed
> > physical RAM, paging of memory-mapped file contents is probably not
> > much of a problem.
> >
> > What's more, since the kernel manages memory globally, it can
> > optimize with more comprehensive information than any single
> > process (easily) could.
>
> It's not a RAM disk. It still has to write the data to disk which you
> don't want when you're just passing data between processes.

No, it does not. The kernel is free to delay writes as long as it likes.
And even when it does write a page, it does so asynchronously.
Write-behind (and read-ahead) is essential to ordinary file I/O and
they apply equally well when the file's contents are mapped into a
segment of RAM. In fact, even better, since there's no need to copy
from one address space to another as their is with ordinary writing
(or, for that matter, with network and other device I/O).

Certainly, some access patterns will be more problematic and harder for
the VM system to cope with than others, but if you're sharing data
among several processes, a memory-mapped file (fragment) is a very
efficient way to do it.


> Bob


Randall Schulz

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.