Chapter 51. cpu load measurements, Cpu load api, Cygcpuloadcalibrate – Comtrol eCos User Manual

Page 649: Cygcpuloadcreate, Cygcpuloaddelete, Cpu load measurements, Cyg_cpuload_calibrate, Cyg_cpuload_create, Cyg_cpuload_delete, Cyg_cpuload_get

Advertising
background image

Chapter 51. CPU Load Measurements

CPU Load API

The package allows the CPU load to be estimated. The measurement code must first be calibrated to the target it is
running on. Once this has been performed the measurement process can be started. This is a continuous process,
so always providing the most up to data measurements. The process can be stopped at any time if required. Once
the process is active, the results can be retrieved.

Note that if the target/processor performs any power saving actions, such as reducing the clock speed, or halting
until the next interrupt etc, these will interfere with the CPU load measurement. Under these conditions the mea-
surement results are undefined. The synthetic target is one such system. See the implementation details at the foot
of this page for further information.

SMP systems are not supported, only uniprocessor system.

The API for load measuring functions can be found in the file

cyg/cpuload/cpuload.h

.

cyg_cpuload_calibrate

This function is used to calibrate the cpu load measurement code. It makes a measurement to determine the CPU
properties while idle.

void cyg_cpuload_calibrate(cyg_uint32

*calibration);

The function returns the calibration value at the location pointed to by

calibration

.

This function is quite unusual. For it to work correctly a few conditions must be met. The function makes use of
the two highest thread priorities. No other threads must be using these priorities while the function is being used.
The kernel scheduler must be started and not disabled. The function takes 100ms to complete during which time
no other threads will be run.

cyg_cpuload_create

This function starts the CPU load measurments.

void cyg_cpuload_create(cyg_cpuload_t *cpuload,

cyg_uint32 calibrate,

cyg_handle_t *handle);

The measurement process is started and a handle to it is returned in

*handle

. This handle is used to access the

results and the stop the measurement process.

cyg_cpuload_delete

This function stops the measurement process.

void cyg_cpuload_delete(cyg_handle_t handle);

545

Advertising