NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

each thread loads a new instance of same dll

I have a sequence file using a dll. this sequence file has station model as batch model (parallel execution) for each test socket index. Is it possible for each test socket index(each thread) to load the same dll separately? Is it possible for teststand to achieve loading a new instance of dll for each thread?

0 Kudos
Message 1 of 4
(4,941 Views)

That's not really how the Windows operating system works. Generally only one copy of a dll is loaded per process. What exactly are you trying to do? It's very likely there is a solution to the problem that does not involve loading multiple copies of the dll.

 

-Doug

0 Kudos
Message 2 of 4
(4,919 Views)

Yes I am aware how windows works but I asked this that there may exist a way to show the second thread as a new process and load the dll second time.... My problem is that I have a dll having global variables which are NOT arrays. And I want each thread(runstate.testsocket.myindex in batch mode parallel execution) running simultaneously the same dll to have separate dll file globals. Is there any other way for this purpose?

0 Kudos
Message 3 of 4
(4,909 Views)

You could use a call exe step to launch separate instances of the UI with the sequence you want to run specified as a command line parameter. Passing the results back to the controling process could then be done using a TestStand queue or serializing them to disk. There is also the remote execution feature, but that would only give you one additional process per machine not one per thread.

 

If you have the source code to the dll, you might want to consider making changes to that instead since that would likely give you a cleaner architecture that would be easier to maintain and debug. I have a couple of ideas for how you could do this:

 

1) Instead of using globals, you can dynamically allocate an object or data structure and pass the pointer to the object or data structure into teststand (TestStand 2010 and higher support storing pointers in Object Reference variables), then for each function call teststand can pass the pointer back into your dll as one of the parameters and your dll can get the per-thread data from the passed in object or data structure.

 

or

 

2) Depending on the programming language the dll uses, there's also the possibility of using thread-local variables in the dll instead of regular globals. With thread local variables you wouldn't even have to change the sequences at all, just access the thread local variables instead of the global variables.

 

Hope this helps,

-Doug

Message 4 of 4
(4,893 Views)