LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How does priority assignment work in RT

If I have my primary VI set to time critical...how does RT handle the remaining VIs which may be set to the other 4 priority levels...are they time threaded proportional to their priority level?
0 Kudos
Message 1 of 6
(4,000 Views)
LabVIEW RT uses preemptive thread scheduling. A VI set to run at time-critical priority will always run until it sleeps (by calling Wait, Wait until next ms multiple, etc). Once it begins sleeping, LabVIEW RT schedules the next highest priority VI to run. If the time-critical VI wakes up, it will interrupt (or preempt) the VI currently running. The interrupted or preempted VI will resume execution if/when the time critical VI goes back to sleep.

If several VIs of equal priority are running simultaneously, LabVIEW RT uses round-robin scheduling in which each VI shares the CPU for 10 ms at a time.
0 Kudos
Message 2 of 6
(4,000 Views)
Question Bob...how are the non-critical VIs treated if they are at different priority levels? For example, say there is one time-critical VI and four non-critical VIs, high priority, above normal priority, normal priority and background priority. How is processor time (RT execution time) divided up amongst these four non-critical VIs when the time-critical VI is asleep? Assume there is no resourse sharing conflicts.
0 Kudos
Message 3 of 6
(4,000 Views)
Troy:

The preemptive scheduling routine I described for time-critical priority applies to all priority levels. So, for instance, a background priority VI will always get preempted by any VI higher than background priority.

normal preempts background,
above normal preempts normal,
high preempts above normal,
and time-critical preempts high

Note that one time-critical VI cannot preempt another time-critical VI. The only way two or more time-critical VIs can run in parallel is if they each sleep on their own accord. Round-robin scheduling is not used for time-critical priority VIs, and that is why we always recommend that you have at most 1 time-critical VI in your application.
0 Kudos
Message 4 of 6
(4,000 Views)
Regarding non-critical time VIs, how do I 'make' time for lower priority VIs to run? Can I use the wait to next multiple primative to put the higher priority VIs to sleep (much in the same way we use it in the critical time VIs)?
0 Kudos
Message 5 of 6
(4,000 Views)
Yes, you'll need to use Wait or Wait Until Next ms Multiple primitives inside continuous loops to ensure that lower priority VIs can execute. Without enforcing sleep in a high priority VI, for instance, no VIs below high priority will be allowed to run.

In addition to these two primitives, there are a few articles on the developer zone about AI SingleScan.vi and Counter Control.vi. These DAQ VIs can also induce sleep (only in LabVIEW RT). In fact, they are your only options for inducing sleep lasting less than 1 millisecond...because Wait and Wait Until have millisecond resolution.
0 Kudos
Message 6 of 6
(4,000 Views)