Hello,
I have an interesting quandry that I can't find any concrete discussion about, so hopefully someone here can help:-
I'm trying to organise inter-process communication (Win32, although the mechanics are internally similar to Linux), between a process that creates image data, and one or more processes that read from it. The image data is fairly substantial (taking up around 8 MB) and is ideally updated several times a second.
There needs to be synchronisation between the processes so that the readers aren't currently reading when the writer wants to update. With this in mind, I would like the readers to be able to pull information as fast as possible.
At the moment, the data is shared between the processes using a shared memory section (CreateFileMapping/MapViewOfFile). The pages are using PAGE_READWRITE protection semantics, but I was thinking that if I change this to PAGE_WRITECOPY, then do dummy writes from each reader process, they would very quickly receive a private copy of each page of the data. This may be faster than using memcpy() myself.
So, can anyone explain what happens when a process writes to a page using copy-on-write semantics? Does the (NT) kernel still do VirtualAlloc for a new page and then memcpy() in kernel mode, or does it do something cleverer and faster?