Re: Named Shared "memory" or "file"?



sawer wrote:
Is using CreateFileMapping/MapViewOfFile functions means sharing
"Memory" or "File" on the disk?

I compiled that code for both
http://msdn.microsoft.com/en-us/library/aa366551(VS.85).aspx

-INVALID_HANDLE_VALUE, // use paging file (that is on the disk)
and
-"C:\\a.txt" //physical file too.

All of them works. And second process can show "Message from first
process".

The second process calls:

1-) OpenFileMapping to get handle

2-) MapViewOfFile.

What is happening here?

Does
second process get handle to physical "file" which is on the disk and
get "Message from first process" string which is written by first
process to file.

or
Second process get handle to first process' physical "memory" and get
string from its address space?

Are they communicating with writing/reading s"ame file"(pagefile or
another file) on the disk or "same memory"?

Well, either and both, and whether you pass a filename or not really doesn't
affect it.

When there's enough memory, you're sharing memory. Even if you specified a
disk file, the data will be in cache. When memory is tight, the cache might
get flushed to disk. Of course you can't actually use the data when it's on
disk, it always has to be read into memory for you to process. It is both
"same file" and "same memory". The only important thing is that the OS
maintains coherency, whether you're sharing L1 cache, L2 cache, local RAM,
NUMA-distributed memory resources, hard disk cache, or hard disk sectors
depends on system load and your hardware configuration.

In practice, CreateFileMapping and MapViewOfFile work together to map the
page from the VMM/disk cache manager into your process address space.


Msdn Documentation which is about procedure for sharing data with
CreateFileMapping/MapViewOfFile/OpenFileMapping is confused me.
Thanks.


.



Relevant Pages

  • Re: What can I check to fix system performance?
    ... it seems you have plenty of memory available: ... copies of files you have read of written lately, in a cache, in case ... processes per CPU, or 40 in all. ... Consider the disk structure. ...
    (comp.os.linux.setup)
  • Re: Caching control
    ... |> | invalidate/unmap them in order to discard the data from memory. ... |> writing out to disk. ... | easy to discard as clean disk cache. ... stating that a specific amount of RAM can be used only for I/O ...
    (comp.os.linux.development.system)
  • Re: Scheduler: Process priority fed back to parent?
    ... > interactivity cache could estimate interactivity over a period of hours ... Then you don't even have to write it to the filesystem. ... For those of us with enough memory or a large variety of programs, ... That way the file is already in disk cache or on its way when the ...
    (Linux-Kernel)
  • Re: FreeBSD and poor ata performance
    ... Linux doesn't really have raw disk devices. ... All disk I/O is through the disk cache, ... performance (on a system with sufficient memory to hold all of the data ... sys 0m12.477s ...
    (freebsd-questions)
  • Re: is there a user mode way to flush disk cache
    ... > arrived on the disk. ... Cache contains data that is already present on ... For that you have the bdflush controls on buffer ... I suspect there is a text on memory tuning in the ...
    (comp.os.linux.development.system)

Loading