Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Creating Deterministic Applications Using VIs Set to Different Priorities (RT Module)

LabVIEW Real-Time Module 8.2 Help
August 2006

NI Part Number:
370622D-01

»View Product Info

Separate time-critical tasks from non-time-critical tasks and place time-critical tasks in different VIs to ensure they receive enough processor resources. You can prioritize the VIs and then categorize them into one of the available execution systems to control the amount of processor resources each VI receives.

LabVIEW assigns each VI to an execution system thread according to the VI priority and execution system you specify. The threads execute on the processor accordingly.

Assigning Priorities to VIs

You can change the priority of a VI by right-clicking the VI in the Project Explorer window and selecting Properties from the shortcut menu to open the VI Properties dialog box. Select Execution from the Category pull-down menu in the VI Properties dialog box to open the Execution Properties page where you can set the priority of a VI. You can select from the following VI priorities, listed in order from lowest to highest, to assign VIs to an execution system thread:

  • normal priority (lowest)
  • above normal priority
  • high priority
  • time-critical priority (highest)

Normal priority is the default priority for all VIs you create in LabVIEW. The time-critical priority preempts all other priorities. A time-critical priority VI does not relinquish processor resources until it completes all tasks. However, a time-critical VI can explicitly relinquish control of processor resources to ensure that the VI does not monopolize the processor resources. SubVIs inherit the priority of the caller VI. For example, a subVI called in a time-critical VI runs at time-critical priority.

Note  Because time-critical priority VIs cannot preempt each other, create only one time-critical VI in an application to guarantee deterministic behavior.

In addition to the four priority levels listed above, you can set VIs to subroutine priority. VIs set for subroutine priority do not share execution time with other VIs. When a VI runs at the subroutine priority level, it effectively takes control of the thread in which it is running, and it runs in the same thread as its caller. No other VI can run in that thread until the subroutine VI finishes running, even if the other VI is at the subroutine priority level.

Assigning VIs to an Execution System

You can change the execution system of a VI by right-clicking the VI in the Project Explorer window and selecting Properties from the shortcut menu to open the VI Properties dialog box. Select Execution from the Category pull-down menu in the VI Properties dialog box to open the Execution Properties page where you can set the execution system of a VI. LabVIEW has the following six execution systems to help you categorize VIs:

  • user interface
  • standard
  • instrument I/O
  • data acquisition
  • other 1
  • other 2

By default, all VIs run in the standard execution system, but you can assign VIs to other execution systems. In addition to the six execution systems, you also can assign subVIs to the same as caller execution system. The same as caller execution system runs subVIs in the same execution system as the top-level VI that called the subVI.

Every execution system except user interface has a thread queue to execute VIs at the priority you specify. For example, if you have three VIs assigned to an execution system, at any time, one VI might run as the other two wait in the queue. Assuming all VIs have the same priority, one thread runs for a certain amount of time. The thread then moves to the end of the queue, and the next thread runs. When a thread completes, the execution system removes the thread from the queue.

The user interface execution system handles all user interface tasks. The other execution systems are not responsible for managing the user interface. If a VI needs to update the user interface, the execution system passes the task responsibility to the user interface execution system, which updates the user interface.

Cooperatively Yielding Time-Critical VI Execution

Because of the preemptive nature of time-critical VIs, they can monopolize processor resources. A time-critical VI might use all of the processor resources, not allowing lower priority tasks, such as lower priority VIs and the FTP server of an RT target, to execute.

You must build time-critical VIs that periodically yield to allow lower priority tasks to execute without affecting the determinism of the time-critical code. By timing a time-critical VI, you can yield the VI and cooperatively relinquish processor resources.

RTX The execution system of the RTSS supersedes Windows scheduling. For this reason, VIs that monopolize processor resources prevent Windows processes from executing. Windows returns an RTX starvation timeout error. You must allow Windows processes enough processor resources to run by including sleep in RT target VIs.


Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit