04-03-2019 11:39 AM
Hi all,
I wanted to know the details difference between master slave and producer consumer design pattern in LabVIEW.
Till now what I get is as follow:
1.Master slave uses notifiers and producer consumer uses queues.
2.In master slave data is broadcast and every slave loop gets that. While in PC the data is consumed by one consumer will not be available in another consumer.
3.PC uses queues so they gives buffered communication i.e. data is buffered in queue so data loss is avoided, while in MS the consumer loop should be enough fast to avoid data.
I have read that master slave supports the communication between two process that run simultaneously at different rate but if the running rate of slave loop is slow then , will data loss or not? in-spite of different rate, could it be slave faster than master?
is there any other differences?
related to application in which they will be used?
Related to synchronization?
04-03-2019 12:26 PM
You are essentially correct.
Let's look at an example of each
Pull out the continuous measurement and logging project template. Why, well it has an example of each, and saves me from writing the examples, documentation and comes with a developer walk through video.
The data acq loop is a Queued Message handler QMH responding to UI commands but acts as a Producer for the logging loop and a Master for the measurement loop.
We use a lossless queue to buffer the log data P-C pattern because we want all data logged but don't care if it is logged now, or as the machine has resources to write to the file. We also use a highly optimized file format to make the writes fast as we can.
The measurement display however is a Slave loop. The user can't really see every single change so, we get latest notifications periodically to show on the UI and keep those slow eyeballs from seeing a blur.
04-03-2019 10:50 PM
Sorry I did not get clear idea.
could you please elaborate with the merits and demerits of both the pattern?
What are the main purpose or application that require these Pattern?.
Both pattern supports asynchronous & parallel communication.
But how do they differ?
only Queues has support of buffering , what in case notifiers?
04-04-2019 02:24 AM
@Yeshwant_Biradar wrote:
I have read that master slave supports the communication between two process that run simultaneously at different rate but if the running rate of slave loop is slow then , will data loss or not? in-spite of different rate, could it be slave faster than master?
In any pattern, if you have more data then you can process, you'll either lose data or crash with an out of memory.
MS\PC are just means to an end. The same end as well probably. You might as well through SMs, QSMs, AF, and who knows what in the mix. All of them can implement pretty much everything\anything. What fits best is mostly based on personal experience and preferences, and just a tiny bit on the application. The range of what you can do in each of them is overlapping so much, that specific strengths disappear in the noise...
In other works, which is best for what soon will boil down do 'ifs', 'buts' (one 't') and 'it depends'.
04-04-2019 07:53 AM
Regarding the differences between Master/Slave and Producer/Consumer.....
Queues, Notifiers and such are almost irrelevant in this regard. It's true that some kind of buffering is normally assocciated with either, but it's not a strict requirement. Both entities exchange data. Both entries can run at different rates. It depends on what you're trying to do.
I've tried to succinctly describe the main fundamental differences and have failed a couple of times. But it's certainly not defined on the method of data exchange.
04-04-2019 09:28 AM
I would say the idea is very similar, but looking at Wiki regarding M/S it says "Master/slave is a model of communication where one device or process has unidirectional control over one or more other devices." while
A P/C queues up commands but doesn't have unidirectional control of a device (necessarily), but in principle they are similar and to a degree i'm splitting hair to almost create a difference.
/Y
04-04-2019 09:46 AM
And even if there is a significant difference, what matters is what you need. If you have a PC and want a MS, or vice versa, it shouldn't be that much work when properly written.
Now I've seen companies where a PC was used for everything 'because that was the template'... That's when it's time to run.
04-04-2019 11:55 AM
wiebe@CARYA wrote:
And even if there is a significant difference, what matters is what you need. If you have a PC and want a MS, or vice versa, it shouldn't be that much work when properly written.
Now I've seen companies where a PC was used for everything 'because that was the template'... That's when it's time to run.
And, just to be clear. These are terms as defined in LabVIEW Core II training. Master, slave,producer and consumer have different meanings in other contexts.
04-05-2019 03:29 AM
@JÞB wrote:
wiebe@CARYA wrote:
And even if there is a significant difference, what matters is what you need. If you have a PC and want a MS, or vice versa, it shouldn't be that much work when properly written.
Now I've seen companies where a PC was used for everything 'because that was the template'... That's when it's time to run.
And, just to be clear. These are terms as defined in LabVIEW Core II training. Master, slave,producer and consumer have different meanings in other contexts.
Just google master\slave, to find out!