title: DLL thread safety
body: <p>I am developing a DLL in MS VC express c++ that will be loaded in multiple client applications at the same time, the DLL has a shared memory space created using <code>data_seg(".SHARED_SPACE_NAME")</code>. In this shared memory space there are some vectors that can be modified.
  Lets assume we have a function in the DLL body called doCalc():</p>
  
  <pre><code>_DLLAPI void __stdcall doCalc(int argument)  
  {  
      //Add to vector  
      //Loop through vector  
      //Erase from vector  
      //etc.  
  }
  </code></pre>
  
  <p>If <code>doCalc</code> is called at the same time from two or more client applications the system will crash.
  I want the doCalc calls to "wait in line" for the previous call to finish - like it was a single-threaded application.
  So that if client 1 calls and then immediately after client 2 calls, then client 1 should finish the function, and then client 2 should run the function.</p>
  
  <p>The best solution would be to run the DLL as a single thread but I have searched the internet a I do not think it is possible.</p>
  
  <p>I have tried searching the internet for this issue, and I have come up with something about making the function <code>static</code> would make it thread safe.</p>
  
  <p>I have also read that C++0x somehow will make this thread-safe. But that it is not supported in MS VC express.</p>
  
  <p>I have no experience in multithreading, so I hope you can help. Thanks in advance.</p>