Certification

cancel
Showing results for 
Search instead for 
Did you mean: 

CLD-R p2 q27

Solved!
Go to solution

The answer is 4 but

 

Reentrant VIs (Preallocate)-
If you use the preallocate clone for each instance option, each caller is given its own private data space (and clone). If there are 20 calls to the VI, 20 clones will be created and added to the pool when the calling VI begins. It may be that only 2 are ever busy at the same time if the calling pattern is like the one described above. If it is important that every call to a given instance of the subVI use the same clone (for example, if the subVI nees to hold data from call to call) then use this type of reentrant VI. Shared clones would not work because you would never know which instance of the subVI last used the clone you are about to use, and the stored information would "cross talk" unpredictably between the subVIs. The "preallocating" means that for every call, we create a data space and clone for that call. The preallocation happens before the VI runs. If you want to open multiple front panels of the same VI, reentrant SubVI options will not help.To open multiple instances of a VI, you have two options:

 

seems to suggest the answer should be 3 not 4. Can anyone explain how the answer is 4?

 

Thanks,

Sean

0 Kudos
Message 1 of 7
(7,013 Views)
Solution
Accepted by SeanJ

Why only 3?  I see 4 instances of the subVI.  1 in the FOR loop and 3 outside of the loop.


GCentral
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 2 of 7
(7,008 Views)

Doh, I totally misread the question.  I thought the three outside the FOR loop were illustrating the three calls inside the FOR loop.

 

This is interesting, so a VI inside a FOR loop is only cloned once no matter how many times it is called?

0 Kudos
Message 3 of 7
(7,005 Views)

SeanJ wrote:This is interesting, so a VI inside a FOR loop is only cloned once no matter how many times it is called?

Yep.  It is more of each time the VI is placed on a diagram, not how many times it is called.  This is a very important concept.  The LabVIEW Field Journal had a good series on maintaining state.  You really should read it through.  Part 1 can be found here.


GCentral
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 7
(7,003 Views)

You are missing just a few other minor points about the clone pool.  SO lets do a brief review assuming a VI (Reenterant Prealocate).

 

When a caller loads into memory LabVIEW will create a "Clone pool" or a copy of the vi dataspace for each clone.  By DEFAULT this is one dataspace per locical processor.  You may call the preallocate method to create more clones in the clone pool (this will increase memory needs) you cannot preallocate less than the default number of clones.

 

if a clone dataspace is avaliable in the clone pool each instance of the sub-vi will check out a dataspace from the clone pool operate on it and release the dataspace when the caller goes idle (Clear data).

 

If a clone dataspace is not available in the clone pool a new dataspace is added to the clone pool (takes time and memory increases at this point) and checked out to the caller and handled the same as before.

 

The destruction of dataspaces (memory dealocation) happens so far under the hood that I suspect if anyone knowledgable about it told you when it happened they would preface their comments with "For versions x-z and subject to change at any future point"

 

 


"Should be" isn't "Is" -Jay
Message 5 of 7
(6,996 Views)

@crossrulz wrote:

SeanJ wrote:This is interesting, so a VI inside a FOR loop is only cloned once no matter how many times it is called?

Yep.  It is more of each time the VI is placed on a diagram, not how many times it is called.  


The important exception is of course if you use a parallel FOR loop. Now a clone is created for each parallel instance. 😉

Message 6 of 7
(6,985 Views)

@JÞB wrote:

SO lets do a brief review assuming a VI (Reenterant Prealocate).


I think what you are describing applies mostly to shared clones reentrant, but maybe I am misreading...

Message 7 of 7
(6,984 Views)