Re: Multiple instances of a single DLL

Tech-Archive recommends: Fix windows errors by optimizing your registry



Stefan, Nikolaos,

Thanks for your replies.

Yes, my dll contains global data, which is the root of my problem.
Sorry, I should have been more specific about it.

I initially ruled out TLS for a reason that I now realize was stupid. I'll investigate that route.

Thanks for pointing out the limit on threads per process.

Serge.
http://www.apptranslator.com - Localization tool for your C/C++ and MFC applications


"Nikolaos D. Bougalis" <nikb@xxxxxxxxxxxxx> wrote in message news:_9hej.26808$db7.8758@xxxxxxxxxxxxxxx
Stefan Kuhr wrote:
Hello Serge,


Serge Wautier wrote:
<snip>
The code of the data logger can also be compiled as a DLL and loaded by a Windows exe that acts as a virtual machine to simulate the device. Very helpful for basic debugging.

Now I want to load test the server (the device sends its info to a web server by GPRS).

My idea is to create a bunch of threads. Each thread is a single virtual machine, therefore owns a copy of the data of one DLL 'instance'.



As long as your DLL doesnt have per-DLL-instance data (read: "globals"), you need not make copies of your DLL to simulate your virtual machine. However, if your DLL uses globals, there is no other way than what you already proposed.

Please don't answer questions to which you don't know the answer to. That's _EXACTLY_ what TLS is for. You can find out more about how it works and how to use it on the nice MSDN page that explains how it works: http://msdn2.microsoft.com/en-us/library/ms686749.aspx.


-n

.



Relevant Pages

  • Re: Multiple instances of a single DLL
    ... Yes, my dll contains global data, which is the root of my problem. ... I initially ruled out TLS for a reason that I now realize was stupid. ... If you don't have the DLL source code, then you basically will require a separate process to host each instance of the DLL, it's the only way for the data addresses placed in the code by the compiler to refer to different instances, because each process gets its own page table. ... His original post detailed a single process with multiple threads, each of which had its own copy of certain global variables, which is exactly what TLS is. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Multiple instances of a single DLL
    ... Yes, my dll contains global data, which is the root of my problem. ... I initially ruled out TLS for a reason that I now realize was stupid. ... Do you have the DLL source code? ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Probleme mit __declspec(thread)
    ... Statically declared TLS data objects can be used only in statically loaded ... This fact makes it unreliable to use static TLS data in a DLL ...
    (microsoft.public.de.vc)
  • Re: Multiple instances of a single DLL
    ... In fact I myself use TLS all over the place in my code. ... mentioned that might even turn out be more problematic: Renaming the DLLs will lead to excessive collisions of the DLLs preferred load address, so with each DLL instance, not only data, but also the code will have to be duplicated in the processes virtual address space. ... This way a single thread can even work with multiple instances of what was before the per-DLL-global data, ... It always boils down to the question whether you want to have implicit state that the DLL's code deals with and several popular libraries go exactly the way Ben proposed, e.g. JPEGLib and zlib com to my mind. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Multiple instances of a single DLL
    ... Yes, my dll contains global data, which is the root of my problem. ... I initially ruled out TLS for a reason that I now realize was stupid. ... If you don't have the DLL source code, then you basically will require a separate process to host each instance of the DLL, it's the only way for the data addresses placed in the code by the compiler to refer to different instances, because each process gets its own page table. ...
    (microsoft.public.win32.programmer.kernel)