01-11-2019 02:20 AM
I have been in one discussion of producer and consumer architecture of labVIEW.
One thing that I can not answered that , what if you use arrays over queues in LabVIEW?
As we can make array of cluster and can insert elements in the producer loop and can be takem back in the consumer loop.
what is makes queues so unique?
is it related to memory or performance?
what is that array can not do over queue?
01-11-2019 02:31 AM - edited 01-11-2019 02:44 AM
Hi Yeshwant,
what if you use arrays over queues in LabVIEW?
You can use any datatype in a queue, also arrays…
what is makes queues so unique? is it related to memory or performance?
Queues are "unique" in that they support a many-to-one communication…
what is that array can not do over queue?
I don't understand this question (and the whole thread)!
What are you missing when you send arrays through your queue?
01-11-2019 02:39 AM
01-11-2019 02:53 AM
@Yeshwant_Biradar wrote:
what is makes queues so unique?
Queues can be accessed in asynchronous loops. They are by reference data types. Arrays are not. That is in itself not unique, but it is a difference from an array.
@Yeshwant_Biradar wrote:
is it related to memory or performance?
Yes. If you'd use an array, you'd need to write or read with a local variable or a reference to the control\indicator. A local will mean a data copy, a value property will mean synchronization with the display.
@Yeshwant_Biradar wrote:
what is that array can not do over queue?
An array would always need a control\indicator to be accessed in parallel loops. Even if a global is used, the global itself has a control\indicator. And each global instance will make a copy of the data.
You'll find that when attaching data to an array, while removing data in another loop will cause race conditions.
So in loop A you will read the data, attach an element and write the data. In loop B you will read the data, remove an element and write the data. What if both loops read, then both loops modify the data, and then both loops write the data? You'll lose data. That's a terrible race condition. And although the odds might seem small, it will happen! You'll have a nasty bug.
So a queue can be made by putting an array in a DVR. The DVR will resolve the concurrent data access, and prevent race conditions. But it will at best do exactly what a queue does, at worse (and very likely) you'll have tons of bug. You'll always lose performance, as queues are, loke globals, very efficient.
@Yeshwant_Biradar wrote:
I have been in one discussion of producer and consumer architecture of labVIEW.
One thing that I can not answered that , what if you use arrays over queues in LabVIEW?
As we can make array of cluster and can insert elements in the producer loop and can be takem back in the consumer loop.
So in short, yes, you can use an array iso a queue. You'll need to solve concurrency problems, and end up with a less efficient solution for something that does what you need.
Is there any reason why you'd prefer an array over a queue?
01-11-2019 03:05 AM
Thanks for the quick reply!
You can use any datatype in a queue, also arrays
I mean to say that what if we replace queue by array to pass data from producer and consumer?
array also can store data , similarly we insert data in array like en-queue data in queue.
Queues are "unique" in that they support a many-to-one communication…
What does that mean ? Array also can be written by producer and can be read by one consumer
what is that array can not do over queue?
I hope now you get my question
01-11-2019 03:15 AM
great explanation !
So a queue can be made by putting an array in a DVR. The DVR will resolve the concurrent data access, and prevent race conditions. But it will at best do exactly what a queue does, at worse (and very likely) you'll have tons of bug. You'll always lose performance, as queues are, loke globals, very efficient.
what is DVR here?
01-11-2019 03:17 AM
@Yeshwant_Biradar wrote:
Thanks for the quick reply!
You can use any datatype in a queue, also arrays
I mean to say that what if we replace queue by array to pass data from producer and consumer?
array also can store data , similarly we insert data in array like en-queue data in queue.
An array wire will not work like that. Adding to the wire in one loop will not add the data to the wire in the 2nd loop. The only way to access array data in two loops is to use an array control or indicator.
01-11-2019 03:19 AM
01-11-2019 03:21 AM
@Yeshwant_Biradar wrote:
Queues are "unique" in that they support a many-to-one communication…
What does that mean ? Array also can be written by producer and can be read by one consumer
And array wire cannot do that. An array control\indicator\global can do that. But will result in race conditions. So the data access needs to be harnessed by some by reference mechanism. That could be a DVR, or a FGV, or (*sigh*) a queue.
Perhaps you should try to make a PC with an array, to prove your principle. Changes are you'll find it doesn't work, as I'm sure it doesn't. If you think you've succeeded, we'll show you why\how it fails.
01-11-2019 03:23 AM
@Yeshwant_Biradar wrote:
great explanation !
So a queue can be made by putting an array in a DVR. The DVR will resolve the concurrent data access, and prevent race conditions. But it will at best do exactly what a queue does, at worse (and very likely) you'll have tons of bug. You'll always lose performance, as queues are, loke globals, very efficient.
what is DVR here?
DVR = Data Value Reference.
Pretty much like a pointer to the data, but with a bonus of interlocking concurrent data access.