Sign in to follow this  
Ahmet

dll loading

Recommended Posts

I have writed a program which use DLL's to make it has more modular architecture. Main idea to use dlls is make main program more robust to trivial program changes. I think writing trivial codes in dll. Main program calls multiple threads and every thread must call its own dll functions. I am not sure where to load library and where to call those functions. My programing mentality is like that: 1- Before my code is going to fork to threads I have loaded my dll with LoadLibrary function but on runtime it can be loaded multiple times.(LoadLibrary functions handles this situation and load only one handle) 2-Main program calls thread (up to 7) and every threads call its GetProcAddress function for certain task(It will personalize a smart card) Personalization function is big and works for 2-3 second. Every thread will work synchronous with card printer machines, and send-get tcp messages etc. Those are my questions : 1-) Is there a change for those Personalization functions's memories to conflict with other thread's memories? 2-) In runtime main program's threads will call GetProcAddress almost 40 times simultaneously, is it OK? Main program will close the threads after finishing personalization. Thats my questions for now, I have not deployed my code to live systems so I need those infos. Thanks.

Share this post


Link to post
Share on other sites
This is my understanding, someone correct me if I'm wrong.

1. Every process which uses a dll has its own data, for globals and statics. As threads inside a process share the memory space, I believe they share the stuff in a dll aswell.

2. I haven't checked the docs (I think you have) if they explicitly mentions not to be thread safe. I believe GetProcAddress is thread safe though. If you're in doubt, write a unit test or put calls to that function behind a mutex.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this