Programmatic access to a target’s resources allows you to create code that can adapt to changing conditions. For example, you can modify a large project to alter its behavior if a certain resource threshold is reached. This ability to change the demands made on a real-time target can help ensure that high-priority tasks continue to execute. Moreover, direct access to CPU and memory information provides the opportunity to create custom monitoring and logging tools. In LabVIEW, the System Configuration API and RT Utility VIs help you access a target’s system resources.
RT Utility VIs
Located in the RT Utilities palette, the RT Get CPU Loads VI provides a large swath of CPU usage information. This VI allows you to see more than total CPU usage by publishing the computational activity associated with different priority tasks. With this information in hand, you can determine if certain processes are receiving adequate resources and isolate problems in larger projects. As seen in Figure 4, this VI outputs an array of clusters, with each element providing information about the corresponding core.
Figure 4: Using the RT Utilities VIs.
System Configuration API
When you are using NI hardware, the NI System Configuration API provides you with the ability to configure, locate, image, and communicate with your devices. To work with this API, you must have the System Configuration software installed on your real-time targets. Figure 5 shows how you can install this add-on via the LabVIEW Real-Time Software Wizard.
Figure 5: Installing the System Configuration API.
You can use a System Session property node, Property Node (System).vi, to access information about a device’s volatile and nonvolatile memory. Figure 6 shows how the Initialize Session VI provides the appropriate target reference for this property node. When configuring the System Session property node, you can find memory information under the System Resources heading.
Figure 6: System Session Property Node.
Additionally, you can use Find.vi to extract the necessary hardware references to execute System Hardware property nodes such as Property Node (Hardware).vi. Figure 7 shows how System Hardware property nodes provide further insight into a target’s behavior. However, you must be careful with which hardware resources you pass to the property nodes.
Figure 7: Using property nodes to monitor target’s behavior.
When working with property nodes, be sure to follow best programming practices and close references using the System Configuration API’s Close.vi. Also, memory reporting for NI Real-Time Linux OS targets differs from expected behavior and is outlined in this KnowledgeBase article.