winapi - CreateFileMapping and MapViewOfFile with interprocess (un)synchronized multithreaded access? -


i use shared memory area som data second process.

the first process uses createfilemapping(invalid_handle_value, ..., page_readwrite, ...) , mapviewoffile( ... file_map_write).

the second process uses openfilemapping(file_map_write, ...) , mapviewoffile( ... file_map_write).

the docs state:

multiple views of file mapping object coherent if contain identical data @ specified time. occurs if file views derived file mapping object backed same file. (...)

with 1 important exception, file views derived file mapping object backed same file coherent or identical @ specific time. coherency guaranteed views within process , views mapped different processes.

the exception related remote files. (...)

since i'm using shared memory (backed paging file) have assumed synchronization needed between processes see coherent view of memory process has written. i'm unsure synchronization needed exactly.

the current pattern have (simplified) this:

process1                    |  process2 ...                         |  ... /* write shared mem, */  |  ::waitforsingleobject(hdataready); // real code has error handling /* then: */ ::setevent(hdataready);     |  /* read shared mem after wait returns */ ...                         |  ... 

is enough synchronization, shared memory?

what sync needed in general between 2 processes?

note inside of 1 single process, call setevent constitute full memory barrier, isn't clear me whether holds shared memory across processes.

use semaphore should better event.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -