LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Re-entrant modes

Solved!
Go to solution

Having read http://digital.ni.com/public.nsf/websearch/98847B4E4C715E6D86256C59006B57CC?opendocument&Submitted&&... and chat with other LV users I still dont know what are the differences between "Share clones between instances" and "Preallocate clone for each instance".

 

As second one is preety intuitive to understand the fist one very confusing.

 

First of all:

  1. What is shared?
  2. What is a clone?
  3. What is data space?
  4. What is an instance?
  5. Why in the article linked above once the phrases 'data space' and 'clone are used as the synonims and for second time are used as excluding phrases?
0 Kudos
Message 1 of 9
(6,465 Views)

What is shared?

 

The sub vi that you are making as clone

 

What is a clone?

 

A clone is a child of the parent vi (Normally sub vi) that you make as reenterant and you will not be able to edit the clones. When you edit the sub vi it will get reflected in all the clones.

 

What is data space?

 

Am not really sure about the data space mentioned here

 

What is an instance?

 

When I create a sub vi and if I pull that into another vi that is called an instance of the sub vi created in another vi. so if Ctrl + drag it I will get seperate instance of that sub vi.

 

Am not sure about the last point as well

 

( I tried to give my understanding and if anyone finds it wrong please correct it and explain the actual scene )

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 9
(6,462 Views)

Let's first start what happens if a subVI is not reentrant. That is the default.

 

Not reentrant (the default):

There will only be one single subVI used by all instances placed on your diagram. If you call it in only one place, you only have one instance. If you call it in several diagram locations, you have several instances that all point to the same subVI. If one part of the diagram calls the subVI, other parts that call the same subVI need to wait. If you have an uninitialized shift register, it will retain data between calls. This data is shared. A very useful feature, allowing the construction of action engines, for example. The content of the shift register can be used as a global storage.

 

---> One VI is shared by all instances on your diagram.

 

Reentrant (preallocate clones):

Whenever you place a copy of such a subVI on the diagram, LabVIEW creates a clone that is completely independent from any other clones of the same subVI. It is like a new VI with the same name. They can all be called and run in parallel. If they contain e.g. uninitialized shift registers or feedback nodes, each maintains its own dataspace (For example it is a temperature sensor, each clone can maintain its own temperature history). Your VI will use N times more memory.

 

---> each instance on your diagram is unique and independent.

 

Reentrant (share clones):

If you call a reentrant VI in many locations and the VI does not store internal data (e.g. in a shift register), it is often not really necessary for LabVIEW to create 100% of the clones, because it unlikely that all of them are called at the same time. For example if you use the subVI in 100 places, maybe the maximum number of real concurrent calls is 10. By enabling shared clones, LabVIEW will only generate 10 clones in this case. This give you the benefit of reentrancy at a smaller cost in memory and resources. Since you have fewer clones than calls, they are shared. (This mode also allows recursive calls, where the number of clones needed is unknown).

Message 3 of 9
(6,444 Views)

Kudo, Christian.
Very precise and well presented. I like the order that you have selected to cover the topics.

0 Kudos
Message 4 of 9
(6,413 Views)

Thanks a lot altenbah.

 

Your answer is most solid I ever seen in this subject. And I've seen quite a lot. I've read the LV help files, on-line NI documentation, official NI training materials for Preformance and Advanced LV architectures trainings. Even on the training I couldn't get clear answer.

 

What you wrote is 'intuitive' correct. However, I cannot to tie up that what you wrote with that what NI said. Nevertheless, I believe that your interpretaion is correct.

 

To NI: Why the NI cocumentation cannot be wirite like altenbach wrote?!? This is really not complicated matter, so why confused people with the words and misleading conjunctions I've enumerated in the first post after reading document linked?

 

But I'd need one clarification more on the share clones mode.

 

In this mode we are not upfront allocating the memory for each clone (clone as the instance of the same VI). We are alocating that dynamically, on-the-fly. Doing so we are saving the memory and that is the USP (Unique Selling Point) of this feature. Am I right? So, how come the shift registers can be exposed on cross-talk situation?

 

Using the example you presented about 100 places of calling the same VI in the share clones mode in which real 10 concurent calls are occuring. What will happen if the suddenly 11th call will occur? Is the clone of 1st call has to be unloaded and the memory space released this way will be reused tor that 11th clone? Is it the 'sharing'? Is it the situation when the shift registers to be exposed for cross-talk?

 

Frankly speaking, intuitivelly, I think when 11th clone will be called in the memory the separate place for it will be dynamically created; and all 11 clones will be working pararelly in their own and designated for them memory space, so it looks like it is neither the sharing nor the risk of cross-talk won't exist.

 

So what the 'stare clone mode' is?

0 Kudos
Message 5 of 9
(6,374 Views)

The "shared clone" mode will reuse memory space.  If a shared reentrant VI is used in 100 places and only 5 run at the same time, then only 5 clones will be made.  If instance 1 completes and then the VI is called again from another location, the first clone will be reused.  So you will have cross-talk issues.

 

You might want to check out the LabVIEW Field Journal.  Brian has a good discussion about this going in his last 3 posts.


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 6 of 9
(6,359 Views)

Does it mean the memory is allocated on-the-fly but not released inthe same manner?

 

For how long the not used clone of the VI is kept in memory, being in ready-to-use state for potential different calls?

0 Kudos
Message 7 of 9
(6,354 Views)
Solution
Accepted by MimiKLM

@MimiKLM wrote:

Does it mean the memory is allocated on-the-fly but not released inthe same manner?

 

For how long the not used clone of the VI is kept in memory?



For "shared clones", memory is allocated as needed (on-the-fly).  The clones will not be released until the main VI that calls them leaves memory.  Seriously, go to LabVIEW Field Journal.  The only reason I knew this answer is because I just read about it there.


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
Message 8 of 9
(6,346 Views)

Thanks a lot crossruls and altenbach. It is really a very good article.

0 Kudos
Message 9 of 9
(6,336 Views)