Possible Duplicate:
DLL thread safety
Hi
Im writting a DLL file in MS VS C++ express, which is loaded in multiple client applications at the same time, it uses shared memory with the other instances of the loaded DLL. Let us assume the DLL looks something like this:
#include stdafx.h
#pragma data_seg (".TEST")
//Shared variables
#pragma data_seg ()
#pragma comment(linker, "/section:.TEST,RWS")
_DLLAPI void __stdcall doCalc()
{
//Do critical stuff
}
If doCalc is called simultaneously from two or more clients the system will crash.
How would I create a Mutex that “stalls” other calls if the function has already been called?
Please give an example, as I have spent the last two hours trying to find a decent one on the internet 😉
Thanks in advance.
The code of every process: