Minimizing CPU Usage on an RT Controller
- Updated2023-02-17
- 2 minute(s) read
Minimizing CPU Usage on an RT Controller
By targeting CPU usage well below 100%, you can minimize jitter and ensure that the tasks in your application do not need to compete for CPU time. Refer to the following guidelines for minimizing CPU usage in your real-time application.
- Create a time budget to determine the amount of time required to execute each task in the application.
-
Use the Real-Time Trace Viewer to identify which VIs and threads in your application use the most CPU time. You can then adjust them based on the following guidelines:
-
Run loops only as fast as necessary.
Running each loop in your application as fast as possible can lead to undesired timing behavior, including increased jitter and even system deadlocks. For example, running the data publishing loop of a user interface faster than the human operator can process and respond to the data can unnecessarily tax the CPU of the real-time target. In most cases, a rate of 2 Hz to 15 Hz is adequate for a loop that publishes user interface data over the network.
-
Avoid excessive parallelism.
Executing code in parallel can increase performance on multi-core systems, but greater parallelism also leads to greater overhead, which can impact performance. To determine whether a VI can benefit from parallelism, you might need to benchmark both the serial form and the parallel form of the VI.
-
Consider offloading certain tasks to either a desktop PC or an FPGA.
Use the following guidelines to determine the most appropriate device for performing specific types of tasks.
Task Appropriate Devices Data acquisition RT or FPGA Control loop RT or FPGA Data analysis for logging or monitoring purposes (offline analysis) RT or Desktop PC Data logging RT or Desktop PC
-
Run loops only as fast as necessary.
Related Information
- Determining Where to Run a Task in a Real-Time System
In a real-time system, you can choose to run a task on one of a few different targets. However, where you run the task depends on the timing, performance, and reliability requirements for your application.
- Creating a Time Budget
Minimize CPU usage and jitter in your application by creating a time budget for each task in your application. To create a time budget, you must determine the amount of time required to execute each task and set the rates of the loops accordingly.
- Minimizing Jitter in a Deterministic Loop
The variation between the expected timing and the actual timing for a task is known as jitter. Minimize jitter in deterministic loops to ensure precise timing in your real-time application.