Menu

multithreading with devc++

mmm kay
2008-04-16
2012-09-26
  • mmm kay

    mmm kay - 2008-04-16

    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!

     
    • cpns

      cpns - 2008-04-18

      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

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.