kid joe wrote:
Quote:
Hi
>
I need to share about 10 MB of data between two processes. In the first
process, I do something similar to:
>
HANDLE hBuffer = CreateFileMapping(INVALID_HANDLE_VALUE, NULL,
PAGE_READWRITE, 0, 10000000, "This is a test");
// <- Check for errors
void *buffer = MapViewOfFile(hBuffer,FILE_MAP_WRITE, 0, 0, 0);
// <- Check for errors
// <- Write something in the buffer
>
In the second process:
>
HANDLE hBuffer = OpenFileMapping(FILE_MAP_WRITE, false, "This is a
test");
// <- Check for errors
void *buffer = MapViewOfFile(hBuffer, FILE_MAP_WRITE, 0, 0, 0);
// <- Check for errors
// <- Read all the buffer
>
What I read is what was written, which is okay. The problem is that, in
the second process, it is about 10 (ten) times slower to read the buffer
that was allocated in the first process than to read another 10 MB
buffer allocated in the second process itself. Is it normal? Is there a
way to share memory more efficiently?
>
Thanks
>
Joe
>
Hi Joe.
1) You open the read part with FILE_MAP_WRITE... why? If you are just
going to read it would be better to ask for read access only. If not,
the synchronization problems could bog you down.
2) You have to experiment with different setups... What about a pipe?
Or other solutions? Just look the documentation in MSDN.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32