From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop to dequeue element isn't running

I am learning Labview and queueing and dequeuing. I have a loop that I have been playing with that queues an element when a switch is flipped. If I dequeue that element immediately in the same while loop then it dequeues just fine so I know it is being queued. When I add a additional while loop the loop never runs.

 

Why?

 

0 Kudos
Message 1 of 6
(1,362 Views)

I can't see your Vi because I don't have the correct LV version loaded on this computer, but there are a few things I can think of.

 

  • You may have a dependency from one loop to the other.  If you have a wire coming out of a loop and going into the loop that won't run, you have created a data flow dependency.  Because the second loop cannot run until all of the inputs are satisfied, and the first loop will not have data at the outputs until it finishes, your second loop will not run until the first loop completes.
  • The other thing is that after you dequeue an element, it is gone.  If you are trying to dequeue the data in more than one place, every dequeue will try to grab the data and remove it from the queue literally by creating a race between all the dequeues to see who will get the data.  There can only be one winner and all the rest will be losers.  So if you have two loops trying to dequeue the same queue, and one loop runs a lot slower than the other loop, it may never get to be the winner, and the loop will never get to run.
Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 6
(1,336 Views)

I checked; it is indeed a data dependency from one loop to the other.

0 Kudos
Message 3 of 6
(1,323 Views)

Yep. I do understand about dequeuing. 

 

This did not work:

flycast_1-1619625405418.png

 

This worked:

 

flycast_0-1619625340788.png

 

0 Kudos
Message 4 of 6
(1,307 Views)

Wires that exit a loop (while or for loop) will not execute until the loop they are exiting completes. So in your case that doesn't work, the dequeue doesn't see the enqueued data until the top loop completes.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 5 of 6
(1,298 Views)

@flycast wrote:

Yep. I do understand about dequeuing. 

 

This did not work:

flycast_1-1619625405418.png

 

This worked:

 

flycast_0-1619625340788.png

 


Now we might run into bullet #2 in my previous post.  if both of those loops are trying to dequeue from the same queue, you may end up with said race condition.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 6
(1,288 Views)