01-09-2013 12:53 AM
Hi
I found a strange sympton, when I use LabVIEW dll with re-entrance and run it in parallel, sometimes the clone dll will reuse thread id with the other one.
For example:
I have two subVIs to call LabVIEW dll in reentrance. they are running in parallel (in different while loop ) . the 1st's thread id is 11, the 2nd one is 12. then I let the 2nd thread retrun and call again( loop 2),it will reuse thread id 11. At this moment, I let 1st thread return, but the problem was happened. the 1st thread was blocked, and it can't return util the 2nd thread return. the program was run in sequential at that time, not in parallel.
My question is: Is there any way to create new thread for each reentance call, and not use the thread id which has been used by another clone instancel?
How to work around this issue?
I use LV2009 SP1 ft5
01-09-2013 04:00 AM
I have a hard time to understand your desciption. If loop2 is running in thread 11 the second time, i would expect loop1 to execute in thread 12 is started again. Obviously, that is not the case.
Can you post your code in order to SEE what you are doing exactly?
Please also state your LV and OS version.
thanks,
Norbert
01-09-2013 04:12 AM
01-09-2013 06:18 AM
As below I have two while loops(their code are the same, each subvi uses reentrance). they are runing in parallel and they call LV dll (builded by LV) inside the read circle sub vi. when the first iteration, the upper loop run the dll in Thread 11 ( I saw the thread ID from Trace tool kit provided by NI), the lower loop run the dll in Thread 12. Then I let lower loop run the 2nd iteration. At this moment, the lower loop would be switched to thread 11 by LV. Then I let upper loop run the 2nd iteration. Dut to the upper loop still use thread 11, so the upper loop was blocked. and it will be blocked until the lower block finshed its iteration.
01-09-2013 06:24 AM
I am not sure if it is related to LV dll (build by LV). My question is if it is possible to create new thread for each reentrance instance ? and how to avoid reuse thread which has been used?
01-09-2013 06:34 AM
Several questions and some feedback.
Feedback:
1. Next time, please provide the VIs, not screenshots. Screenshots cannot show all aspects of the issue, so you get better/faster response when showing all aspects immediatly by providing the real sources.
2. Your screenshots are quite small and not easy to read.
3. Readability of the screenshots is also affected by bad wiring practice and Rube-Goldberg code segments. Please try to improve your wiring skills and add some comments to make the code easier to be understood.
4. To get rid of one obvious Rube-Goldberg code: Replace your Number to Boolean and the array logic with a simple "Not Equal To 0?" primitive. Also you might reconsider using a while loop at all.
Questions:
1. How do you prove that loop 1 is waiting for loop 2 in the second iteration? What is the content of the DLL to make this "visible"?
2. I would expect that the VI calling the DLL is also configured to be re-entrant. Otherwise, the VIs might be called from different threads, but only one instance can run at a time. This is expected behavior. You are aware of this?
hope this helps,
Norbert
01-09-2013 07:24 AM
Yes, as Norbert says,we need to see code - including what the DLL is doing, screenshots are not useful.
What abouthte other VI in the loops, is it also reentrant? What kind of reentrancy is being used (there are 2 different types)?
Mike...
01-09-2013 10:14 AM
1. the LV dll is a dialog,it was implemented by while loop with a stop button. when the LV dll was called, the dialog will pop up. If I push the stop button,then the dll call would return to caller subvi, then the loop will go to next iteration.
2. Yes, the LV dll was reentance. I knew this issue.
3. I afraid I can't provide the code, due to it is not my property. can you give me the email,maybe I can send to you in private.
01-09-2013 10:23 AM
@nerogior wrote:
[..]2. Yes, the LV dll was reentance. I knew this issue.[..]
I am not talking about the DLL function nor the Call Library Function Node (CLFN). I was talking about the VI which includes the CLFN....
Norbert
01-09-2013 10:43 AM
Yes, the VI which include CLFN is reentrance also. So shouldn't I set it to reentrance?