LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW: What makes queues better that array? we can use array as data type to insert element into it and can be read back

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?

 

0 Kudos
Message 1 of 12
(2,334 Views)

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?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 12
(2,329 Views)

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?


Or are you comparing queues and arrays? they are completely different things.

Certified LabVIEW Architect
0 Kudos
Message 3 of 12
(2,325 Views)

@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?

Message 4 of 12
(2,312 Views)

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

 

 

 

0 Kudos
Message 5 of 12
(2,307 Views)

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?

 

 

0 Kudos
Message 6 of 12
(2,302 Views)

@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.

 

 

0 Kudos
Message 7 of 12
(2,297 Views)

@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.

0 Kudos
Message 9 of 12
(2,290 Views)

@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.

Message 10 of 12
(2,285 Views)