11-30-2010 09:25 AM
Hi Experts!
A long time passed since my last post, so here it is! 🙂
I have function global for only prupose - to store data. I have two paralell loops, that calls this FG, for setting and getting data without any synchronization.
My only question is, what's happen when both loops operate on FG? (FG is not reetrant)
All data set and get procedures are completed in booth loops, without unexpected error?
The method is simple, so there is no case for set and get the same data on same time, only different.
I.e: Loop1 - Put : String_1 , Loop_2 - Put : String_2, or Loop_1 - Get: Number , Loop_2: Set String
Thank you!!!!
Solved! Go to Solution.
11-30-2010 09:29 AM
Hi,
the purpose of the FGV is to capsulate such data accesses. So you can call the FGV in two parallel loops - one call will wait till the other call is finished!
And don't make the FGV reentrant, this will "hurt" the performance of your FGV
11-30-2010 09:35 AM
Thank you!
11-30-2010 09:38 AM
I don't understand the purpose. If two locations randomly write to the same FGV from different locations, things are not very deterministic. Since the stored value at any time critically depends on execution order of the various "writers", the outcome of a read operation cannot be predicted by looking at the code. This typically qualifies as race condition.
If you would make it reentrant, it would no longer be "global", because each instance on the block diagram would be a separate instance and keep it's own data. What use is that? You might as well just use a shift register. 😉
Maybe I misunderstood what you meant. 😉
11-30-2010 09:41 AM
My prupose is, try to use FG as a Global data storage in paralell loops. Thats all .. .:)
11-30-2010 09:41 AM
My prupose is, try to use FG as a Global data storage in paralell loops. Thats all .. .:)
11-30-2010 09:42 AM
@altenbach wrote:
I don't understand the purpose. If two locations randomly write to the same FGV from different locations, things are not very deterministic. Since the stored value at any time critically depends on execution order of the various "writers", the outcome of a read operation cannot be predicted by looking at the code. This typically qualifies as race condition.
If you would make it reentrant, it would no longer be "global", because each instance on the block diagram would be a separate instance and keep it's own data. What use is that? You might as well just use a shift register. 😉
Maybe I misunderstood what you meant. 😉
Re-entrant AE used to be common when we had to poll the GUI and needed value change detection. They can also be used for running averages.
Ben
11-30-2010 09:58 AM - edited 11-30-2010 10:00 AM
@Ben wrote:
Re-entrant AE used to be common when we had to poll the GUI and needed value change detection. They can also be used for running averages.
Yes, that is a valid use, but then we lose the "G" in "FGV". 😮
I guess the "AE" definition is wide enough to allow both.
I was just trying to point out the conflicting statements in the thread title. 🙂
11-30-2010 10:09 AM
BTW, I have two Loops, and every Loop calls one (same) VI with VI-server. (the called vi is only a function i.e.: Add 2 values)
Any Ideas?
11-30-2010 10:34 AM
Durnek wrote:Any Ideas?
Not really. There are millions of possible VIs that fit that description. Why don't you show us some code instead. 🙂
What kind of ideas are you looking for? (prettier, faster, better, clearer, easier to maintain, ...?)