LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Function Global - Reetrant

Solved!
Go to solution

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!!!!

---
+++ In God we believe, in Trance we Trust +++
[Hungary]
0 Kudos
Message 1 of 10
(4,603 Views)
Solution
Accepted by topic author D60

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 Smiley Wink

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(4,600 Views)

Thank you!

---
+++ In God we believe, in Trance we Trust +++
[Hungary]
0 Kudos
Message 3 of 10
(4,590 Views)

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. 😉

 

0 Kudos
Message 4 of 10
(4,582 Views)

My prupose is, try to use FG as a Global data storage in paralell loops. Thats all .. .:)

---
+++ In God we believe, in Trance we Trust +++
[Hungary]
0 Kudos
Message 5 of 10
(4,577 Views)

My prupose is, try to use FG as a Global data storage in paralell loops. Thats all .. .:)

---
+++ In God we believe, in Trance we Trust +++
[Hungary]
0 Kudos
Message 6 of 10
(4,577 Views)

@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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 10
(4,574 Views)

 


@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. 🙂

0 Kudos
Message 8 of 10
(4,548 Views)

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?

 

---
+++ In God we believe, in Trance we Trust +++
[Hungary]
0 Kudos
Message 9 of 10
(4,535 Views)

 


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, ...?)

0 Kudos
Message 10 of 10
(4,520 Views)