如果 VI 处于 FOR 循环中,预分配克隆是否只分配一个克隆?
Does preallocate clone only allocate one clone if a VI is in a FOR loop?
我正在参加 CLD-R 之前查看样本试卷。
我遇到了如下所示的重入问题:
答案是 4。
中的 for 循环中没有具体提及预分配
The "preallocating" means that for every call, we create a data space
and clone for that call.
上面建议答案是6,总共有6次调用,但答案是4。这是否意味着在FOR循环中只为一个VI分配了一个克隆?
Does this mean that only one clone is assigned for a VI in a FOR loop?
是的。相关术语是 "call site",在 help 中您可以找到:
In reentrant execution, LabVIEW allocates multiple instances, or clones, of the data space so that each call site, or usage of the subVI on the block diagram of the caller, can execute simultaneously, in parallel, such that each call site uses a separate clone.
由于 VI 位于代码中的一个位置,因此可以重复使用。当您编写一个具有有用状态(如反馈节点)的 VI,然后您天真地在循环中调用它,期望循环的每次迭代都有自己的副本和自己的状态时,这就变得非常重要,结果却发现所有迭代共享相同的状态。
我正在参加 CLD-R 之前查看样本试卷。
我遇到了如下所示的重入问题:
答案是 4。
中的 for 循环中没有具体提及预分配The "preallocating" means that for every call, we create a data space and clone for that call.
上面建议答案是6,总共有6次调用,但答案是4。这是否意味着在FOR循环中只为一个VI分配了一个克隆?
Does this mean that only one clone is assigned for a VI in a FOR loop?
是的。相关术语是 "call site",在 help 中您可以找到:
In reentrant execution, LabVIEW allocates multiple instances, or clones, of the data space so that each call site, or usage of the subVI on the block diagram of the caller, can execute simultaneously, in parallel, such that each call site uses a separate clone.
由于 VI 位于代码中的一个位置,因此可以重复使用。当您编写一个具有有用状态(如反馈节点)的 VI,然后您天真地在循环中调用它,期望循环的每次迭代都有自己的副本和自己的状态时,这就变得非常重要,结果却发现所有迭代共享相同的状态。