CPU Idle Value Measurement Using Hardware and Idle Counters
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Conventional methods for measuring CPU idle value in embedded systems with Linux-based operating systems are inaccurate due to the multitasking nature of Linux, which leads to incorrect CPU idle value measurements because tasks do not align with system ticks, resulting in misleading idle system status.
Innovation Solution
An idle value measurement apparatus that includes a hardware counter and an idle counter, configured to continuously increment and pause based on CPU clock signals, with instructions to calculate the idle value as a ratio of total increments of the idle counter to the hardware counter during a predetermined period, allowing for accurate CPU idle value measurement.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Ease of operation
If the native Linux idle calculation based on system ticks is used, then the measurement approach is simple, but the measurement precision deteriorates because tasks do not align with system ticks on embedded systems
Solution Approach 1:
The patent introduces an intermediary idle counter that runs independently of the Linux scheduler and system ticks. This counter is enabled/disabled by the idle task to directly measure CPU idle time, acting as a mediator between the idle task execution and the measurement mechanism, thereby resolving the misalignment between tasks and system ticks
Solution Approach 2:
The patent replaces the software-based Linux idle calculation mechanism (which relies on system ticks and scheduler accounting) with a hardware-based counter system. The hardware counter provides continuous, high-resolution timing independent of the Linux scheduling granularity, substituting the flawed software mechanism with a more accurate hardware-based measurement
2Measurement precision
If the conventional idle task approach with dummy jobs is used, then the measurement precision is high, but the device complexity increases due to requiring hard real-time operating system support
Solution Approach 1:
The idle task in the patent performs dual functions: it serves as the traditional idle task that executes when no other tasks are ready, and simultaneously acts as the measurement mechanism by enabling/disabling the idle counter. This self-service approach eliminates the need for separate measurement infrastructure while maintaining compatibility with Linux
Solution Approach 2:
The idle task is designed to be multi-functional: it maintains system operation by executing idle work and simultaneously performs measurement by controlling the idle counter. This universal approach allows a single component to serve multiple purposes, reducing overall system complexity while achieving accurate measurement
3Ease of operation
If the Linux scheduler dedicates system ticks for each task, then the task scheduling is simplified, but the measurement precision deteriorates because tasks run on fractional system ticks
Solution Approach 1:
The patent moves the measurement from the time dimension (system ticks) to the task execution dimension. Instead of measuring based on fixed time intervals that may not align with task boundaries, the measurement is tied directly to task execution events (idle task enabling/disabling the counter), achieving accuracy without sacrificing scheduling simplicity
Data Source
AI summary
In a method, system and apparatus for measuring an idle value of a Central Processing Unit (CPU) in an embedded system, the CPU increments a hardware counter in accordance with clock signals. The CPU also increments an idle counter during a predetermined period of time in accordance with the clock signals while an idle task is running. The CPU calculates the idle value as a ratio of total increments of the idle counter to total increments of the hardware counter after the predetermined period of time has expired.


