Loading...
You are not logged-in Login/Register





  • Posts   Search Threads
  • sorcer76August 24, 2007 1:04 PM PDT   
    TBB mutex not safe in Windows shared DLL?

    I have heard that the mutex object simply uses Critical Sections in Win32.  This is very fast for a process, but isn't safe in a DLL that is used by multiple processes.

    Is this true?


    Robert Reed (Intel)August 24, 2007 2:58 PM PDT
    Rate
     
    Re: TBB mutex not safe in Windows shared DLL?

    Yes, TBB::mutex object uses Enter|LeaveCriticalSection in the Windows implementation and pthread_mutex_lock|unlock otherwise.  Each of these are meant to operate within a process, avoiding the overhead incurred for interprocess communication.

    So what about shared DLLs?  While the "text" of a shared DLL (the instructions and constants parts) are shared among processes, the "data" part is not.  Each belongs to the respective process.  In fact, you have to go to some extremes to share memory between multiple instantiations of a DLL.  It's possible and there certainly are DLLs out there that use shared memory to moderate communications between multiple processes, but this is not the norm.

    So, if you use tbb::mutex in a DLL that only uses parent process data, you should not have to worry about thread safety issues using tbb::mutex.  But if you're DLL is moderating between multiple processes, the data structures involved will need stronger (slower) protections.



Forum jump:  

Intel Software Network Forums Statistics

17,025 users have contributed to 48,321 threads and 172,753 posts to date.

In the past 24 hours, we have 16 new thread(s) 57 new posts(s), and 54 new user(s).

In the past 3 days, the most popular thread for everyone has been How to manage rounding by IVF ?? The most posts were made to Most likely, the issue is that The post with the most views is Optimalization of sine function\'s taylor expansion

Please welcome our newest member redfruit83


For more complete information about compiler optimizations, see our Optimization Notice.