What is the best and safest way of sharing cluster data between 2 timed loops running. I could use locals, but that is risky, would shared variables work better? All I need to do is modify a couple of datatypes in a cluster that both threads use.
You could go the LVOOP route and create a singleton object. The object can be passed to parallel tasks an dsince it is singleton they will all share the same value. Ue of a DVR inside the object would allow you to have a single copy of the data. Your class would also give you the necessary accessors for reading/writing data.
Would this be the proper way to handle the functional global. I need to modify a data cluster from within another timedloop, but don't want to create a race condition doing it. I could use queues I guess too. But if this is thread safe, I'd rather use this method.
It depends on how you want use. If you use FGV you can read the same value many time but when it goes for the data logging this may not be desirable. You can use the queue so that whenever you update the data you will be able to read it and you have the buffer so chance of data loss is very less.
Here is a functional global example: https://decibel.ni.com/content/docs/DOC-2143
And another one: https://decibel.ni.com/content/docs/DOC-20897
Basically, the functional global is a simple VI which you can call in 2 or more parallel running loops and/or VI's. You can read, write, or somehow manipulate the data stored in a uninitialized shift register of the FGV while loop based on the 'Action' selection (case structure).
It is pretty simple to use and very easy to implement. You can use 'First call?' or maybe 'init' action in order to initialize the shift register.
Thanks guys that is helpful. Is there an example that maybe shows how this might be used though with multiple loops accessing the same functional global data loop since the examples just shows how to set it up. I guess I'm still a bit uncertain how to incorporate this method into my main test application that has 4 task loops running together. Is the functional global data that all 4 tasks access in separate loop with the uninitialized shift register? If there is an example of this actually implemented that would be helpful. Thanks so much.
Be careful with functional globals. And there is a holy war going on here regarding the use of locals. There is a plethora of options in your Synchronization palette. I would suggest getting very familiar with methods there. Plenty of examples.