Table Of Contents

Minimizing Jitter in a Deterministic Loop

    Last Modified: April 18, 2016

    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.

    • Refer to the following guidelines for interacting with deterministic loops:
      • Memory allocation— Pre-allocate arrays before using them in deterministic loops. Use the Replace Array Subset node to modify pre-allocated arrays within a deterministic loop. Use the Real-Time Trace Viewer to identify Wait for Memory system event flags, which indicate memory management operations.
      • Opening and closing references—Open references in an initialization phase before entering a deterministic loop. Close references in a shutdown phase after the deterministic loop terminates. Opening and closing references inside a loop can add jitter in a deterministic loop.
      • Communication—Use the RT FIFO nodes to communicate with a deterministic loop. RT FIFOs buffer data so that a deterministic loop can access the data without being blocked by a lower-priority loop.
      • SubVIs—For best performance, use inlined subVIs in deterministic loops. Inlined subVIs decrease CPU overhead because they do not need to be called at run time. If you do not use inlined subVIs, close all subVI documents before running a VI that contains a deterministic loop.
    • Avoid placing the following items in deterministic loops:
      • File I/O—Accessing the hard disk using file I/O operations can introduce unbounded jitter in a deterministic loop.
      • Networking operations— Networking operations can introduce unbounded jitter in a deterministic loop.
      • Variable-size data structures—Using variable-size data structures in deterministic loops leads to variation in loop execution times. Instead, pre-allocate memory before using a data structure in a deterministic loop.
      • Shared resources—Accessing resources that are shared between a deterministic loop and another loop, such as hardware resources, I/O channels, or non-reentrant subVIs, may cause the deterministic loop to wait for the other loop to release the shared resource.
      • Shared data—Sharing data with a deterministic loop through objects such as queues, data value references, and duplicated terminals can introduce jitter in a deterministic loop . Instead, use RT FIFO nodes to communicate with a deterministic loop.
      • Algorithms with unbounded jitter—Certain algorithms are non-deterministic by nature and can introduce unbounded jitter. Do not include algorithms with unbounded jitter in a deterministic loop. If you are not sure about the jitter characteristics of a program, benchmark it.
      • Controls and indicators—Placing data terminals within a deterministic loop can negatively impact performance, which introduces jitter.

    Recently Viewed Topics