Differences Between Reentrant, Template, and Dynamic VIs

您所在的位置:网站首页 静态模板是什么意思 Differences Between Reentrant, Template, and Dynamic VIs

Differences Between Reentrant, Template, and Dynamic VIs

2023-05-24 19:28| 来源: 网络整理| 查看: 265

SolutionReentrant VIs

Reentrant VIs are used when you want to run several instances of the same VI simultaneously. When the聽VI is not reentrant, there is one data space for the VI. Therefore, only one caller at a time can be running the聽VI, and聽so a caller may have to "wait its turn" to use the VI.聽 This is the default option for a VI, but you can set a聽VI to be reentrant. There are two types of reentrancy: shared and preallocated.聽

Shared Reentrant VIs 聽 If the聽Shared clone reentrant execution聽option is selected, the VI has a pool of data spaces (same thing as a pool of clones). Initially only two clones are created when the calling VI begins. A caller will use one of these data spaces, but it doesn't know which one, and it may be a different聽instance on subsequent calls. When there are not enough data spaces (clones) in the pool for the number of simultaneous callers, new data spaces (clones) are created and added to the pool. Here the word "sharing" from "share clones between instances" means that the data spaces can be used by multiple callers over time. If there are 20 calls to the SubVI, but those calls happen such that at most two calls are going on at the same time, the pool聽will have only two data spaces in it and they聽will be "shared" among the 20 calls. Since only the necessary number of clones is created according to the current need, memory use is optimized. For quickest execution and best memory optimization, this option is recommended.聽 聽 Preallocated Reentrant VIs 聽 If the聽Preallocated clone reentrant execution聽option is selected, 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 two 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 needs 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 "preallocated" means that for every call, a data space and clone for that call is created. 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.

If the VI you want to open multiple times is a top-level VI, you can duplicate the top-level聽VI on disk to a temp directory with a unique name and open the new file instance. It is not necessary to duplicate any SubVIs, only the top-level VI. You can then use the VI Server to open and run the copies.

LabVIEW code can run slowly if several of the same SubVI are聽used within the main VI and they are not聽Preallocated clone reentrant, this is聽because the SubVI's can only be accessed by one location at any given time hence resulting in the code slowing down.

Template VIs

You can make a multi-instance panel into a template VI, then open the file each time from the template. VI templates are VIs with the .vit extension. You can create a new VI from a template under聽File禄New禄Start from template. This creates a new instance of the VI, with its own memory space. These have distinct memory location when created and are just used as starting point for making another VI. You then need to configure whether that new created VI is or is not reentrant.聽

Dynamic VIs

You can open both VIs and聽VI templates with VI Server. VI Server is used to dynamically load and run a VI. With SubVIs, the code and the data space of the SubVI are loaded when the top-level聽VI is loaded. When you dynamically load a VI, instead of using it as a SubVI and loading it when the main program is called, its code will not be loaded until the SubVI is called by the VI Server. This saves memory at startup time.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3