Re: Multiple instances of a single DLL
- From: "Mikep" <mikep@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 2 Jan 2008 16:19:52 -0800
comment inline---
"Serge Wautier" <serge@xxxxxxxxxxxxxxxxxx> wrote in message
news:Ou5tHiYTIHA.1184@xxxxxxxxxxxxxxxxxxxxxxx
Hi Ben,
Thanks for your reply.
Yes, I do have the source code. But moving everything to a common struct
is something I'd rather avoid. That would take too much time. Let's not
even talk about the possible bugs I would introduce.
I'd rather go the separate processes way then.
<quote>
Short story : How can I load a DLL several times in a process? I need to
have multiple copies of the DLL data loaded simultaneously (there will be
one thread acting on each copy).
I thought of simply duplicating the Dll file using different names
(dll1.dll, dll2.dll,.). But it doesn't look very elegant. And I'll need a
few thousands of these copies.
<unquote>
So we have moved from one process hosting a few thousand dll's (and threads)
to a a few thousand processes each hosting one dll???? IMHO, either choice
will be a trainwreck in progress..... Have another look at David L's alarm
bells comment.
Mikep
FYI, another suggestion was to trick the loader by creating hardlinks to
the dll and load instances of it using each hardlink.
Regards,
Serge.
http://www.apptranslator.com - Localization tool for your MFC applications
"Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx> wrote in message
news:OTNwi8XTIHA.1164@xxxxxxxxxxxxxxxxxxxxxxx
"Serge Wautier" <serge@xxxxxxxxxxxxxxxxxx> wrote in message
news:%23c9yN5GTIHA.5288@xxxxxxxxxxxxxxxxxxxxxxx
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.
Do you have the DLL source code? If so, eliminate your global variables
by moving them into a "context" struct which the caller must provide.
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
(short of creating a custom loader that processes fixups) for the data
addresses placed in the code by the compiler to refer to different
instances, because each process gets its own page table. TLS wouldn't
help you.
I don't think TLS is appropriate for your problem. Sounds reminiscent of
"When all you have is a hammer everything looks like a nail".
.
- References:
- Re: Multiple instances of a single DLL
- From: Stefan Kuhr
- Re: Multiple instances of a single DLL
- From: Nikolaos D. Bougalis
- Re: Multiple instances of a single DLL
- From: Serge Wautier
- Re: Multiple instances of a single DLL
- From: Ben Voigt [C++ MVP]
- Re: Multiple instances of a single DLL
- From: Serge Wautier
- Re: Multiple instances of a single DLL
- Prev by Date: Re: Multiple instances of a single DLL
- Next by Date: Re: Multiple instances of a single DLL
- Previous by thread: Re: Multiple instances of a single DLL
- Next by thread: Re: Multiple instances of a single DLL
- Index(es):
Relevant Pages
|