Run consumer loop without waiting

Thursday, December 9th, 2010

Producer/Consumer loop (PC loop) is one of the most important architectures in LabVIEW. It gives a good solution when your data producing rate is faster than your consuming rate. A typical example is analysing/storing the data while acquiring new ones. We dont want any slowness or jag of the post-process  interrupt the acqusition. Thus PC loop create a space from the memory and uses it as a buffer to deal with the asynchronous tasks.

In this architecture, the consumer loop will wait (for timeout period) until there is a new element in the queue. What if we want to run the consumer loop regardless the queue is empty or not? Sometime, we want to output waveforms until new waveform is generated. I modified the PC loop as following:

 

Note: Since the consumer loop runs all the time, we need a ‘wait until‘ node in it to save the CPU. It is not shown in the figure and sorry about that.

So the consumer loop does the normal things (like output pre-defined signals) when there is no element in the queue (determined by state of queue.vi). And when there is, the consumer loop dequeues it and updates the state (like updating signals). I think this thought is logical and similar to human thought. An alternative method is to enqueue the same element after we de-queue it. In this case the loops will be keeping enqueuing and de-queuing. I don’t quite like this method, of which the thought is not straightforward.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: