I am developing a DLL in MS VC express C ++ that will load simultaneously in several client applications, the DLL has a shared memory space created using data_seg(".SHARED_SPACE_NAME"). In this common memory space, there are some vectors that can be changed. Suppose we have a function in the body of a DLL called doCalc ():
_DLLAPI void __stdcall doCalc(int argument)
{
}
If it doCalcis invoked simultaneously from two or more client applications, the system will fail. I want doCalc calls to "wait in line" to complete the previous call - as it was a single-threaded application. Thus, if client 1 calls, and then immediately after calling client 2, then client 1 must complete this function, and then client 2 must start the function.
The best solution would be to run the DLL as a single thread, but I searched on the Internet, I do not think it is possible.
I tried to find this problem on the Internet, and I came up with something about the function staticmaking it safe.
I also read that C ++ 0x will somehow make this thread safe. But this is not supported in MS VC express.
I have no experience with multithreading, so I hope you can help. Thanks in advance.
source
share