DLL and TLS
-
Hi, I have three questions, 1.What happens when several threads use the same DLL? 2.race condition takes place during above situation? 3.The usage of TLS in thread and DLL. Plz in detail. Thank you. Best regard. I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. One concrete prolem is worth a thousand unapplied abstractions.
-
Hi, I have three questions, 1.What happens when several threads use the same DLL? 2.race condition takes place during above situation? 3.The usage of TLS in thread and DLL. Plz in detail. Thank you. Best regard. I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. One concrete prolem is worth a thousand unapplied abstractions.
1. Nothing special. The
DllMain
entry point is called for each newly created thread withfdwReason
set toDLL_THREAD_ATTACH
. 2. No race conditions occur as calls toDllMain
are serialized by the system. As a corollary, threads cannot be created insideDllMain
. 3. TLS routines can allocate and deallocate indexes that are local to each running thread. These usually are used to map some dyamically allocated memory. Check MSDN article Using Thread Local Storage for details. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo