LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

First call? Re-entrant vi

In link below states that  "Reentrant VIs have an instance per data space. Therefore, a shared reentrant VI returns TRUE for each data space instance the first time its top-level caller calls it".  I sounded odd, when it says shared enentrant, I thought I might setting reentrant execution to use share clone.  However, share clone will not give you a data space per instance.  you have to set the eneentrant execution to preallocate clone for each instance for this to work.  Did I get this right?

 

 

https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/first-call.html

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 4
(3,714 Views)
I believe your understanding is correct, so I think that one of three things might be happening: 1. The term "data space" is unclear and actually refers to the actual clone (and you have no way of knowing how many clones there are and which one will be called). 2. The documentation is supposed to refer to prealloc clones and is basically wrong. 3. We're wrong in our understanding and shared clones do somehow know to recognize separate calls. I don't believe this is the case.

___________________
Try to take over the world!
Message 2 of 4
(3,707 Views)

Hm, the quoted help text is mostly correct.

 

"Clone" and "data space" is a synonym if (and only if) the setting of reentrancy is "preallocate clone reentrant execution".

 

If the setting is "shared clone reentrant execution", multiple clones can share data spaces if the exection of the clones (read: clone is running) is sequential (not concurrent).

 

Dynamic execution of the code decides when and which data spaces are re-used for different clones. So it is possible, that one clone "moves" from data space to data space whereas others will re-use "their last data space".

 

That being said, the help is correct in the following meaning:

Each data space includes the "first call" function. So regardless of the clone which is executed in the data space first, the first call will be set. So if another clone shares the data space later on (and is called for the first time), it will see "first call" as false!

 

The help is false in the following meaning:

Reentrant VIs have an instance per data space. This sentence is only true for the setting "preallocate clone reentrant execution" or if all calls to clones are concurrent (sharing not possible).

 

A little messy gets the whole story if the clones are distributed over different calling VIs which are going idle themselfes from time to time (dynamic VIs).....

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 3 of 4
(3,684 Views)

I wouldn't say the documentation is wrong.  I think it is trying to be a warning that if you use Shared Reentrant, then you don't know when the First Call? will return TRUE.  Since with shared clones, another clone is only made when needed.  When this new close is made, the First Call? will return a TRUE.  But if you have two threads calling the same shared reentrant VI so that they are not at the same time, the second thread will see the First Call? as false.

 

It sounds like you have it figured out.  With shared reentrant, you can't say that a call to a VI will be the same clone.

 

Reentrancy can be quite confusing.  The LabVIEW Field Journal had a good series on maintaining state information.  I think it covers this information pretty well.  The first of the series can be found here:http://labviewjournal.com/2012/02/maintaining-state-1/



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4
(3,674 Views)