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: 

Do LV Queues guarantee ordering?

Solved!
Go to solution

When dealing with high speed queues <4ms between writes, and equally fast reads. I'm getting data that is out of allignment. Meaning if I insert

 

      Q <- Insert 1

      Q <- Insert 2

      Q <- Insert 3

      Q <- Insert 4

 

I'll sometimes get

 

      Q.flush() -> [ 1, 3,2,4 ]

 

Is this normal behavior?

0 Kudos
Message 1 of 9
(3,727 Views)

No it's not. Do you have multiple enqueuers?

If so, what makes you sure that 2 enqueues before 3?

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 9
(3,724 Views)

If you are queuing from multiple places, there's no guarantee what will go in first.  That being said, though - if FIFO wasn't the case for each enqueue, none of our code involving queues would be reliable.  Enqueue opposite would have no meaning, either.

 

If you are queuing from only one place, I would check to make sure the data is actually arriving in order.  Maybe you have some kind of race issue that causes values to change before they get queued?

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 3 of 9
(3,713 Views)

1) yes a 2 thread producer consumer loop.

 

1 thread writes, the second thread reads. That's the only 2 times this queue is called (other then its creation).

 

2) The example I provided was a conceptual example, not a literal example. What I'm actually dealing with is 600 index long, 84 index wide 2D 65float array pulled DAQmx.

 

2.5) No changing the size of the read doesn't affect this and changing the time between reads has little effect either.

 

 

0 Kudos
Message 4 of 9
(3,705 Views)

Give us the simplest example of code you can make that shows that behavior. I suspect that something is missing in your story.

Marc Dubois
0 Kudos
Message 5 of 9
(3,688 Views)

Honestly, i understand little to nothing from your post....

So you have ONE producer which enqueues values and ONE consumer dequeueing values. Is that correct?

 

If so, the order of elements you dequeue is exactly the order in which you enqueued unless you are using "enqueue on opposite end".

That being said: What makes you confident that elements are in wrong order?

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 9
(3,683 Views)

My question is about the language specification not about this one instance in general. I know the G programming language will delay execution of a VI until all inputs are saturated. The real question I'm asking is if when rapidly enqueueing objects the G runtime environment will delay the insertion of an object until its VI is avaliable, and if this mechanism is not stricly order via call... Hence the ENQUEUE_VI itself cannot gaurentee that calls to it, will not necessarily be executed in the order that they're called from.

 

I've grabbed some screen shots from the application

 

 

Here is where the DATA leaves DAQmx and enters Queue.

data insert.png

 

That Sync VI is just a VI that ensure the time stamps (derived from To field of the wave form pulled from DAQmx, is always greater then the previous value)

 

SyncData.png

 

So now we get to Dequeue

Dequeue.png

 

Only Novel Data.vi job is to remove data that has been seen before (I.E.: Repeating time stamps, which can occur very very rarely). This VI hasn't presented an issue in the slightest. But as I'm runing DAQmx over 4000/Samples per second I start getting data misorder (customer contract requires this).

 

Its contents

only novel data.png

 

 

Here is the output of all this together. What's graph is my time stamps from mxDAQ this are the raw values, every value I get

 

T0 time stamps.png

 

The issue is lower values are arriving long after higher values. Meaning I'm traveling back in time, or something weird is happening. Lasty the data is only missordered in blocks of ~600 which is my DAQmx Read Size (and each 600 data points is 1 item inserted into the Queue, hence my questions).

0 Kudos
Message 7 of 9
(3,667 Views)
Solution
Accepted by topic author Valarauca

I don't understand what your last picture with the Excel sheet is supposed to show.  I see a bunch of numbers called relative time.  Sometimes they are longer, sometimes shorter.  But they are all positive, nothing looks like it is going back in time.

 

It is hard to debug from a series of pictures that are partial screenshots.  There is no way to tell what is relative to what, what structures are surrounding the elements.

 

I see one enqueue function and one dequeue function.  But the Enqueue is Enqueue at opposite end.  That means you are placing the element at the front of the line cutting ahead of anything that was placed in the queue earlier, but has not been processed yet.

 

I bet if you use the regular Enqueue function, your problem goes away.

Message 8 of 9
(3,654 Views)

>Wrong Queue VI

 

That's what I get for writing code before my first cup of coffee

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