02-24-2009 08:44 PM
Hi all,
I am trying to use the producer/consumer architecture in my program. My producer loop is a analog input acquisition loop. I would like to enqueue the acquired data for 3 separate consumers. The first consumer loop would write the data to a file, the second consumer would send the data to the front panel, and the third consumer would send an analog output based on the data.
It seems to me that if any of the consumer dequeue the data, the other consumers would have nothing left to dequeue. I want them to get the same data at the same time. Do I really have to create 3 queues and enqueue the same data to 3 separate queues? Is there a better way? Thanks!
02-26-2009 11:41 AM
I think this Discussion Forum post may have your answer. Evans response is what I was originally thinking.
02-26-2009 12:31 PM
Hi,
My question is a bit different. The post that you pointed me to address the problem when a master would send a messsage to a particular slave, while multiple slaves aare listening and could take the message, so that the particular slave does not get the message. My question is that when the master send a message, I want all the slave to be able to get the same message and dequeue the same data without creating multiple queues.
02-27-2009 11:07 AM
Hi,
Once you take information out of the queue you can no longer access that data. Thats why I was originally thinking of the preview function because you could access the data and make sure that everyone sees the same thing. This works, but its hard to synchronize. You could try using something like rendevous to make sure the vi's meetup, but even then, it would be hard to make everything synchronous. I also thought that you could possibly use global variables, write to them from the master and read to it from the slaves, because all of the slaves could access it at the same time, but even then you would have to make sure they were at the same rate, and that would eliminate the need of having multiple slaves. So there is no other good way that I can think of to enqueue information so that three different slaves could see it besides using three different queues.
Regards,
03-03-2009 02:44 PM
When I do three seqerate queue, I run out of memory sometimes, since each element is a decent size 2d array. So there is no way to get around this? Thanks!
03-04-2009 11:34 AM
Hello,
Is there a way of getting around uing three different consumer loops? If they need information at the same time, does that mean they are looping at the same rate? Is there a possibility that you could use just one loop?
03-07-2009 05:51 PM
I would like splits out each function into multiple loops, because I would like them to run at different rate, and I would like my program to be more cohesive (grouping similiar function to the same location of code). I am not sure is that the right way to do it though. Let me know what you think. Thanks!
03-09-2009 10:54 AM
Hello,
I guess I am a little confused by why you want the loops to run at different rates, but you want the data updated at the same time. Could you describe what you are doing in your code or submit a screenshot of what you are doing? Also, creating a seperate loop just because code is different is not always a good way to seperate code. Often a subvi is sufficient to group sections of code.
03-09-2009 01:08 PM
03-10-2009 11:38 AM
Hello,
Thanks for providing the additional information about your code. I am still not sure, if you have three loops running at different rates, why you would like to ensure they get the data at the same time. The loops would be moving at different rates and therefore you could not gurantee that they dequeue the information at the same rate even if they arrived at the same time. It still appears that using three queues would be the best solution, and then dequeing the information for each loop when it is needed by the loop, or you could have 2 of the loops use the preview queue function and receive the information that way while the last loop dequeues the information. All of the loops would get the same information, just one loop would dequeueing the information.