Domanda

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

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top