Jump to content

ActiveX locks unrelated loops?


Recommended Posts

Hiya!

I've got a vi which has 2 loops.

Loop1: vi's with dll based IO through a dedicated PCI card.

Loop2: ActiveX-based com through RS232.

ActiveX is quite slow, about 200ms/call, but that's not the issue (although annoying). I check status by polling through 5 activeX calls, thus 1 sec.

The Loop1 easily loops at 3ms if needed, i run it at 30. Lots of time to spare. That is, until i start the 2nd loop. Suddenly Loop 1 runs at 1 sec also and the only explanation i can think of is that ActiveX locks my VI/labview somehow. If i add some small waits between the activex calls loop1 runs a few loops at full speed, then a 200ms loop (the activex time).

Anyone has any idea of how to get around it?

(labview 8.2)

/Y

Link to comment

I've also wrapped the activeX in a VI of it's own and set it to another thread, same with the dll-vi's. The main difference is that i dont get timeouts any longer (as it seems to have broken into the dll sub-vi's).

Yes, somehow they must work in the same thread (probably UI), but it feels very strange, to say the least.

/Y

Link to comment

I've also wrapped the activeX in a VI of it's own and set it to another thread, same with the dll-vi's. The main difference is that i dont get timeouts any longer (as it seems to have broken into the dll sub-vi's).

Yes, somehow they must work in the same thread (probably UI), but it feels very strange, to say the least.

The Call Library Node has its own threading configuration that allows you to select that the DLL function is either called thread safe from the UI thread or in reentrant mode in whatever thread the calling VI is executing. If you have the UI Thread selected in the Call Library Node you can put the VI in whatever execution system you want but in order to call the function LabVIEW will switch to the UI thread first.

I believe that most ActiveX nodes have to be called thread safe at all times, so they will execute in the UI thread anyhow (since most ActiveX components are specified to be apartement threaded, which is to say that an application should always call the Active X component from the same thread and the UI thread is the only thread in LabVIEW where this can be guaranteed without a very complex thread configuration system that nobody would understand.

  • Like 1
Link to comment

I must say neither of your solution really tickle my "oh i must program that"-nerve. :)

I was hoping for just setting the dll call to "any thread" and keep the VI as non-reentrant to protect it but allow it in another thread than the UI one. I checked today, and they are all set to UI thread currently. The drivers are quite old, probably from LV5 or something originally so the multithreading probably wasn't in the design.

A coworker actually did the 2 application test today and it worked well. I dont think any of us has done inter-application solutions before though, so that solution has some hurdles but might be a good solution. I'll have to dig deeper into the different solutions.

/Y

Link to comment
  • 2 months later...

Now i've had time to return and try some more on this issue. Changing the DLL calls to Reentrant and then changing the VI execution thread made alot of difference! I haven't actually tried it coupled with the mentioned ActiveX, but i got similar problems in another program that uses several parallell processess instead. In this one the Open VI-node caused the DLL calls to generate errror 7005 (timeout). The mentioned changes (some 6 dll calls and vi's preferred thread of execution) has solved it beatufully!

Thanks alot Rolf!

(cant mark as solved or something on this forum, can you?)

/Y

Link to comment
(cant mark as solved or something on this forum, can you?)

Nope, but you can vote a post up by clicking the green (+) ball on the lower right of the post. LAVA is more of a forum than a collection of Q&A threads, so we didn't think it made sense to allow members to mark posts as specific categories (like "Solved").

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.