Re: Named Shared "memory" or "file"?
- From: "Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx>
- Date: Tue, 29 Jul 2008 11:09:33 -0500
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.
.
- Prev by Date: Re: CreateSymbolicLink doesn't fail on 64-bit if process doesn't have sufficient privileges
- Next by Date: Build on Server 2003, run on XP?
- Previous by thread: Re: Named Shared "memory" or "file"?
- Next by thread: Creating a compressed folder - programmatically
- Index(es):
Relevant Pages
|
Loading