07-27-2022 10:12 AM - edited 07-27-2022 10:26 AM
I am trying to understand and verify the behavior of the LabVIEW RT scheduler on a multicore CPU.
In this example, I have simplified the problem by using cRIO-9074 that has a single logical CPU.
(Under the hood, the cRIO-9074 target runs LabVIEW RT on the VxWorks RTOS).
I am trying to verify that within one execution system, parallel clones of a single VI are executed in a round robin schedule, because the VI clones should each have the same priority.
Please see the code, below.
The Sub VI: ‘Other 1 Loop Wait 0’ contains a sequence structure. In the first frame of the sequence structure a ‘Wait until next millisecond multiple’ is called. This should synchronize the parallel instances of the VI’s . The second frame of the sequence structure then contains a while loop with a Wait 0 inside. The Wait 0 operation yields VI (thread) execution back to the scheduler, whilst signalling that the VI (thread) is ready to run again.
The execution of the while loops should continue until the set ‘Execution Time’ has elapsed. If the LabVIEW RT scheduler executes each VI (thread?) in a round robin schedule, I expect each instance of the Sub VI to execute the same number of while loop iterations (within one).
Unfortunately, I cannot verify the behavior which is inconsistent and unpredictable.
When the Execution Time (input control) is set to 5 milliseconds or less, each while loop executes the same number of iterations, as expected. But, when the Execution Time is set to more than 5 milliseconds, the while loops execute a different number of times, and the outcome is not repeatable. It seems that the Sub VI clones (threads) are not executed in a round robin schedule. For example, when i set the Execution Time to 100ms, the Sleep counts: 21451, 31936 and 22612 are returned; then 30068, 31505 and 21718; then 21749, 22693 and 31639, etc.
Please can you help to explain the behavior, which could have implications for a real application.
Is it there any way to achieve the expected behavior of round robin execution?