01-09-2013
09:26 AM
- last edited on
04-18-2025
01:48 PM
by
Content Cleaner
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
01-09-2013 09:41 AM
01-09-2013 10:21 AM
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
01-09-2013 10:40 AM
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/