Question

I'd like to understand if there are any hidden issues with using InterlockedCompareExchange() to change a memory in a segment created with CreateFileMapping(INVALID_HANDLE_VALUE) and shared between multiple processes.

In other words, can the processes rely on the CAS semantics to operate with the memory block they share? I assume they can, just want to confirm that.

Thanks

Was it helpful?

Solution

CAS operations will work perfectly well with that memory. The file mapping API and the virtual memory system do all the hard work of mapping the memory into multiple processes. By the time you get your hands on the memory, you can't tell it apart from any other piece of memory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top