Course contentsShow
← Embedded Systems & Computer Architecture
Lesson 504 of 9367. Real-Time Operating Systems (RTOS)Free lesson

Evaluating RTOS Latency and Jitter Metrics

Measure interrupt latency and scheduling jitter to quantify the precision and reliability of your system's real-time performance.

In this lesson, you will learn how to quantify the precision of your real-time system by measuring interrupt latency and scheduling jitter.

In a deterministic embedded system, we don't just care if a task finishes; we care if it finishes on time, every time. To verify this, we look at two primary metrics: Interrupt Latency and Scheduling Jitter.

Interrupt Latency

Interrupt Latency is the elapsed time from the moment a hardware signal triggers an interrupt to the moment the first instruction of your Interrupt Service Routine (ISR) begins execution. This delay is influenced by hardware architecture (pipeline depth) and software constraints (like disabling interrupts during critical sections).

Scheduling Jitter

Jitter is the variance in the timing of task execution. If a periodic task is scheduled to run every 10ms, but sometimes executes at 10.2ms and other times at 9.9ms, the difference is your jitter. High jitter undermines the stability of control loops, such as motor controllers or digital signal processing algorithms.

How to Measure Them

The most effective way to measure these is using a GPIO toggle and an oscilloscope or logic analyzer. By setting a GPIO pin high at the start of your ISR and low at the end, you can visually observe the consistency of the pulses.

// Measuring ISR Latency/Jitter with a logic analyzer
void GPIO_ISR_Handler(void) {
    GPIO_SET_HIGH(TEST_PIN); // Mark start of response
    
    // Perform minimal processing...
    
    GPIO_SET_LOW(TEST_PIN);  // Mark end of response
}

To measure Scheduling Jitter, instrument the start of your periodic task:

void Periodic_Task(void *pvParameters) {
    TickType_t lastWakeTime = xTaskGetTickCount();
    while(1) {
        vTaskDelayUntil(&lastWakeTime, pdMS_TO_TICKS(10));
        
        GPIO_TOGGLE(JITTER_PIN); // Measure the distance between toggles
        // Logic...
    }
}

If you observe the time between JITTER_PIN toggles using a logic analyzer, any deviation from the 10ms interval is your scheduling jitter. By tracking the worst-case timing over a long duration, you can determine if your RTOS configuration satisfies your system's determinism requirements.

Key Takeaway: Measuring the delta between expected and actual execution timing via GPIO instrumentation allows you to quantify your system's worst-case determinism and identify bottlenecks in your task scheduling.