LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Communication between threaded VIs with queues

Hi,
I would like to communicate between VIs (thread structure) with queues. But sending messages with queues increases the memory until crash.
I try to release the queue each time I send new message, but I also destroys the recipient !
Any suggestions for reliable communication between VIs (launched dynamically) -> Like Windows messaging ?
Thanks in advance for your answers.
0 Kudos
Message 1 of 9
(3,835 Views)

You have not to destroy/release queue after each sending.

Open your queue and connect the reference on both loops. So the one loop enqueues the queue and the other one should dequeue them. After you exit both loops you can release the queue.

I use queues very very often (up to 20 queues), but I can't confirm that the memory usage increases.

Eugen

0 Kudos
Message 2 of 9
(3,825 Views)

Hi Eugen,

Thanks for your answer.

You write "Open your queue and connect the reference on both loops". This will work fine if both threads are in the same VI, but I can't do so because they are both in separate VIs, called dynamically... Thats my main huge problem.

Any other suggestions about how communicate between VIs called dynamicaly ? What kind of structure should I use ?

Thanks

0 Kudos
Message 3 of 9
(3,819 Views)

Queues work fine for communicating between different VIs - when you obtain a queue, you have the option of entering a name, which obtains the same queue.

There are two ways in which you can run out of memory:

  1. You enqueue much faster than you dequeue. The queue grows unbounded until there is no more memory. There are several solutions for this. You can define a maximum size for the queue or occasionally flush the queue, but the best solution is usually not to enqueue data unnecessarily.
  2. You obtain the queues in a loop. This produces a new reference each time which consumes memory. The solution is to obtain the queue once.

The real solution depends on what it is you are actually trying to do, but I'm suspecting you might want a notifier - unlike queues, a notifier only maintains the most recent value and so will not grow unbounded.

I suggest you post more details about what it is you want to do exactly. Posting images of your code might also help.


___________________
Try to take over the world!
0 Kudos
Message 4 of 9
(3,815 Views)
If you want to connecgt to an existing queue, you should use a name for your queue. Be sure the datatype is the same on every instance.
Besides that if you close the VI that opened the first instance of the queue goes Idle the queue will die (as far as I know)

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 5 of 9
(3,813 Views)
Here you have an example.
Download All
0 Kudos
Message 6 of 9
(3,810 Views)

And here the screenshot of the Main.vi, which starts both loop-VIs.

 

.



Message Edited by Eugen Graf on 02-06-2008 03:54 AM
0 Kudos
Message 7 of 9
(3,808 Views)
Ok, if you start your VIs dynamically, than you can use the VI server method "Set control Value" to let the VI know the Queue reference.
OR you can open the queue reference in both VIs before the loop. The unique NAME of the queue should be the same in both VIs, than you have the same reference of your queue.
Message 8 of 9
(3,805 Views)

Hi everybody,

 

Thanks for all of this answer. I will try those solutions and check for the memory size usage...

Thanks again.

0 Kudos
Message 9 of 9
(3,743 Views)