LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer/Consumer architecture

In Producer and consumer which loop will run fast and why?

0 Kudos
Message 1 of 5
(2,125 Views)

Often, they'll run at the same average speed.  Sometimes a consumer will purposely run slower and do "batch processing".

 

Generally, the reason one would *choose* a producer/consumer architecture is to unencumber the producer loop.  So generally, the producer is the loop that *needs* to run fast without interruption.

 

 

- Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 5
(2,095 Views)

That's an interesting question.  Please tell us what you think is a sensible answer (I would maintain that there is no "correct" answer, as you haven't defined what you mean by the speed of the loop).

 

Bob Schor 

0 Kudos
Message 3 of 5
(2,094 Views)

As per my understanding , I think it depends on the application to be designed which decides which loop to work faster.

Like few applications require the producer loop to be faster so that it produces queued data which is then processed by the consumer loop at its own pace.

Some applications require the consumer loop to run faster to buffer the queued data and in some applications both the loops run at same pace.

This is my understanding.Please correct me if I'm wrong somewhere 🙂

0 Kudos
Message 4 of 5
(2,067 Views)

Most situations that I've encountered has the Producer running at a relatively-fixed speed, usually driven by a "time-specified" requirement (such as acquiring 1000 points from a DAQ card at 1kHz, a process that takes 1 second but can't be "delayed" by having 10 seconds of processing in the same loop) and one that takes a "flexible" length of time, typically running "as fast as it can" in an attempt to "keep up with" the rate that data are being "produced" by the Producer.  Usually the transfer mechanism (such as a Queue) can "buffer" data to allow the Consumer to "take a little extra time when needed" (say, to open files or query a database), but you don't generally want the Consumer to run significantly slower than the Producer.  Note that just as the Producer often "waits" for much of its Loop time (in the DAQ example noted above, >99% of the time the Producer is waiting for the DAQmx Read to finish and produce the data on its output lines), a well-behaved Consumer should strive to "Consume" at, or slightly faster, than the rate that the Producer "produces".

 

Bob Schor

0 Kudos
Message 5 of 5
(2,048 Views)