So I am using c standard library functions as well as c++ vectors and streams in a win32 GUI application. I'm wondering how to make my program thread safe. Currently when running 2-3 identical threads with different data the threads quickly get mixed up. They are all reading from sockets and parsing data, and they end up all getting the exact same data after awhile, when it should be totally different.
Do I need to use certain thread safe libraries? Currently I am linking libkernal32, libgdi32, and libws2_32. Or need I be using critical sections or socket calls or string manipulation?
I've read about libraries like libcmt32 for thread safe c standard library, but I don't see this in the devc++ libraries. Is there a replacement, or is it automatically thread safe?
Thanks for any help!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
MinGW links msvcrt.dll (Microsoft's dynamically linked C runtime for MSCV++ 6.0) by default as its C library - that is you don;t explicitly link it. This supports multi-threading. Of course that alone does not make your code correct, and the more likely explanation is simply that your code is flawed.
Hey,
So I am using c standard library functions as well as c++ vectors and streams in a win32 GUI application. I'm wondering how to make my program thread safe. Currently when running 2-3 identical threads with different data the threads quickly get mixed up. They are all reading from sockets and parsing data, and they end up all getting the exact same data after awhile, when it should be totally different.
Do I need to use certain thread safe libraries? Currently I am linking libkernal32, libgdi32, and libws2_32. Or need I be using critical sections or socket calls or string manipulation?
I've read about libraries like libcmt32 for thread safe c standard library, but I don't see this in the devc++ libraries. Is there a replacement, or is it automatically thread safe?
Thanks for any help!
MinGW links msvcrt.dll (Microsoft's dynamically linked C runtime for MSCV++ 6.0) by default as its C library - that is you don;t explicitly link it. This supports multi-threading. Of course that alone does not make your code correct, and the more likely explanation is simply that your code is flawed.
All you probably need to know is here: http://msdn2.microsoft.com/en-us/library/y6h8hye8.aspx