I need to do some high bit rate streaming between two processes on the same machine. In order to avoid excessive copying my idea is to allocate a large shared memory buffer (via CreateFileMapping) which will contain the actual data, and use a pipe for control messages.
The idea is that the producer will write a chunk of data to the shared memory then send a message over the pipe, effectively passing ownership to the consumer. The consumer does its business directly on the shared memory, then sends another message to release the memory back to the producer. Repeat ad infinitum.
Is this synchronisation mechanism guaranteed to be safe in terms of memory coherency? I.e., is the consumer guaranteed to see the complete effects of the producer's writes after receiving the control message?