LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Enqueued elements are not dequeued in separate loop

Solved!
Go to solution

Hi, I have two concurrent while loops: the first one is for enqueuing elements from data acquisition. The second one is supposed to run every second (lower speed) to process the enqueued elements which is writing them to a local file.

 

For some reason there is an unexpected behavior resulting in the accumulation of hundreds of elements in the queue without being dequeued, UNTIL the first DAQ loop is done. After that I can see the number of elements decreasing again.

 

How can I accomplish fully concurrent enqueue and dequeue of elements?

0 Kudos
Message 1 of 7
(1,522 Views)
Solution
Accepted by fflo

You seem to be asking; ‘If I enqueue elements faster than I dequeue them, why does the queue fill up?’

"If you weren't supposed to push it, it wouldn't be a button."
Message 2 of 7
(1,501 Views)

We can't help unless you attach your code. Queues will let you dequeue things immediately after you add them, so you likely have something preventing that in your code somewhere.

 

Attach it here and we'll take a look.

Message 3 of 7
(1,490 Views)

Yeah, my bad, I haven't seen it.🙄

0 Kudos
Message 4 of 7
(1,485 Views)

A good option to help mitigate this is rather than dequeue a single data point flush the queue instead. It will give you all of the enqueued items in an array.  Then you just process that array.

 

Another option is don't gate your processing loop with some arbitrary delay tat impacts the loop execution. Rather, dequeue elements as quickly as they arrive and place them into an array and then process that array at your desired intervals. This is basically a different implementation of the first suggestion as the end result is essentially the same.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 7
(1,450 Views)

@fflo wrote:

The second one is supposed to run every second (lower speed) to process the enqueued elements which is writing them to a local file.


The point of the Producer/Consumer is to be able to process the data as fast as possible when data is available.  A consumer loop should never be time limited other than waiting for data to come in from the producer loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 7
(1,402 Views)

You state that the consumer loop only runs after the producer loop is finished.  This would indicate a dependency between the output of the producer loop and the input of the consumer loop.  THINK DATAFLOW. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 7 of 7
(1,351 Views)