Answers inline below…
First, I thank you all,
Daniel Terhell said that:
“Having a pagefile in Windows (at least nowadays) is optional and so must
be all assumptions about disk backing of paged memory”
I am really curious about one thing. Yes, pagefile is optional, maybe
someday it will be gone completely.
Actually, it is already gone today. Windows Embedded, or whatever the
package is currently called, requires enough RAM to hold all the processes
that need to run, because there is no disk at all.
Present or absent, its existence is irrelevant to the basic question; I
forget who posted the answer, but the notion that backing store is
required is a mere implementation decision is correct.
But after that how can memory sharing be implemented? I know all IPC
methods use memory mapped files internally.
Why do you think memory sharing requires memory-mapped files? In fact, it
does not. They are only one way to implement one kind of IPC, so how do
you jump to the conclusion that “all IPC methods use memory mapped files
internally”. What do you base this statement on?
So that means memory sharing needs a disk file existence. Why? I think it
is because we need a handle that represents the resource(I am not sure).
And VirtualAlloc does not return a handle.
No. Not at all. I’m not sure how it is done on embedded systems, but I
know that memory sharing does NOT require a disk file, because for the
last 15 years, one of the exercises in my Systems Programming course is
sharing memory and this exercise involves absolutely NO use of files.
So without usage of a disk file, is it possible to implement memory
sharing? If a new object, say “memory object” is defined, and VirtualAlloc
returns a handle to that memory object, so can memory sharing be
implemented without a disk file involvement??
Shared-segment DLLs, shared-segment executables. VirtualAlloc does not
participate in any of the memory sharing mechanisms I am aware of. And it
most definitely does not return a “handle” to a “memory object”. It
returns a process-local address to non-shared memory accessible to that
process (or NULL, if it fails). In fact, I have no idea why a disk file
would need to be involved at all. So you start with an unwarranted
assumption, and reach an unjustified conclusion. Even “memory-mapped
files” do not require an actual file; if the file given is
INVALID_HANDLE_VALUE, then the sharing is done without an actual disk
file. Older documents suggest that sharing is done via the pagefile, but
as already pointed out, this is an implementation detail, and is not
mandated by the abstract specification. So again, the notion of
memory-mapped “file” is not precluded by the absence of an actual “file”
system (or a writable file system, e.g., EPROM bulk memory).
So re-examine your assumptions. First, the assumption that “all IPC
requires shared memory” is clearly invalid (in the kernel, you can share
information by kernel addresses that is simply not accessible to user
space; it may be “shared” in an abstract sense, but there is absolutely no
actual “sharing”. WM_COPYDATA does not require a disk file system, and
can be used to transmit data from one process to another; whether this is
done by shared memory or some other mechanism is completely irrelevant to
its usage, and it is definitely an IPC mechanism. Registered Window
Messages can pass a WPARAM-sized and an LPARAM-sized data object, and
shared memory is definitely not required for this. You can use unnamed
pipes, named pipes, and mailslots as IPC mechanisms, and no shared memory
is involved. You could even use TCP/IP or UDP for IPC, and no shared
memory is required. I’m sure I can come up with a few more ideas for IPC
that do not require shared memory, so I fail to see how you have leapt to
the conclusion that shared memory is necessary to all IPC mechanisms.
Then the assumption that “a pagefile is required for shared memory” is
seriously questionable. So if you throw these two assumptions out, there
is no problem.
joe
Thanks again…
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer