LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Execution Order inside a While Loop

I have a question on order of the execution of subroutines inside a while loop. Suppose there are multiple subroutines (named Subroutine 1, Subroutine 2, and so on) placed inside a while loop. The subroutines are not wired together (that is, they are independent) and are not placed inside a sequence structure (that is, the execution order of the subroutines is determined by LabVIEW). Suppose, the first time when the while loop is executed (first iteration), the subroutines are executed in the following order: Subroutine 1, Subroutine 2, Subroutine 3, and so on. Will the execution order of the subroutines change for subsequent while loop iterations, such as 2->1->3->.. for the second iteration, 4->1->3->2->.. for the third iteration?

0 Kudos
Message 1 of 3
(2,919 Views)
The order can change as they are not data-dependent. If you want to force a certain order, link the sub-vis together with error cluster inputs and outputs.

If the Sub-VIs have large difference in initialisation times (like generating large arrays) it may be that 99% of the time they execute in the same order, but it`s not guaranteed.

If you need better timing, look into occurrences, notifiers etc. These allow some pretty neat ways of co-ordinating sub-VIs that are otherwise not connected to each other.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 2 of 3
(2,919 Views)
> The
> subroutines are not wired together (that is, they are independent) and
> are not placed inside a sequence structure (that is, the execution
> order of the subroutines is determined by LabVIEW).

The order is predetermined, but only its beginning.

You called the items subroutines. If you really mean they really are
subroutine priority subVIs, then they will not multitask. If they are
set to run in the same execution system, the one that starts first will
finish and then the second will run. If these aren't subroutine
priority, but are really just subVIs, then they will multitask with one
another.

How can you tell which will start first? You didn't specify, so it
could change from compile to compile or from version of LV to version.
As ot
hers have mentioned, if the order is important, either use a
sequence structure or dataflow.

Greg McKaskle
Message 3 of 3
(2,919 Views)