OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [cpuload/] [v2_0/] [doc/] [cpuload.sgml] - Blame information for rev 365

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
2
CPU load measurements
3
4
5
The cpuload package provides a way to estimate the cpuload. It gives
6
an estimated percentage load for the last 100 milliseconds, 1 second
7
and 10 seconds.
8
9
10
11
CPU Load Measurements
12
13
CPU Load API
14
15
The package allows the CPU load to be estimated. The measurement code
16
must first be calibrated to the target it is running on. Once this
17
has been performed the measurement process can be started. This is a
18
continuous process, so always providing the most up to data
19
measurements. The process can be stopped at any time if required. Once
20
the process is active, the results can be retrieved.
21
22
23
Note that if the target/processor performs any power saving actions,
24
such as reducing the clock speed, or halting until the next interrupt
25
etc, these will interfere with the CPU load measurement. Under these
26
conditions the measurement results are undefined. The synthetic target
27
is one such system. See the implementation details at the foot of this
28
page for further information.  
29
30
SMP systems are not supported, only uniprocessor system.
31
32
 The API for load measuring functions can be
33
found in the file cyg/cpuload/cpuload.h.
34
35
36
cyg_cpuload_calibrate
37
38
This function is used to calibrate the cpu load measurement code. It
39
makes a measurement to determine the CPU properties while idle.
40
41
42
void cyg_cpuload_calibrate(cyg_uint32  *calibration);
43
44
45
The function returns the calibration value at the location pointed to
46
by calibration.
47
48
49
This function is quite unusual. For it to work correctly a few
50
conditions must be met. The function makes use of the two highest
51
thread priorities. No other threads must be using these priorities
52
while the function is being used. The kernel scheduler must be started
53
and not disabled. The function takes 100ms to complete during which
54
time no other threads will be run.
55
56
57
58
cyg_cpuload_create
59
60
This function starts the CPU load measurments.
61
62
63
void cyg_cpuload_create(cyg_cpuload_t *cpuload,
64
                        cyg_uint32 calibrate,
65
                        cyg_handle_t *handle);
66
67
68
The measurement process is started and a handle to it is returned in
69
*handle. This handle is used to access the
70
results and the stop the measurement process. 
71
72
 
73
74
cyg_cpuload_delete
75
76
This function stops the measurement process.
77
78
79
void cyg_cpuload_delete(cyg_handle_t handle);
80
81
82
handle should be the value returned by the create function.
83
84
 
85
86
cyg_cpuload_get
87
88
This function returns the latest measurements.
89
90
91
void cyg_cpuload_get(cyg_handle_t handle,
92
                 cyg_uint32 *average_point1s,
93
                 cyg_uint32 *average_1s,
94
                 cyg_uint32 *average_10s);
95
96
97
handle should be the value returned by the
98
create function. The load measurements for the last 100ms, 1s and 10s
99
are returned in
100
*average_point1s,*average_1s
101
and *average_10s respectively.
102
103
104
105
Implementation details
106
107
This section gives a few details of how the measurements are
108
made. This should help to understand what the results mean.
109
110
111
When there are no other threads runnable, eCos will execute the idle
112
thread. This thread is always runnable and uses the lowest thread
113
priority. The idle thread does little. It is an endless loop which
114
increments the variable, idle_thread_loops and
115
executes the macro HAL_IDLE_THREAD_ACTION. The cpu
116
load measurement code makes use of the variable. It periodically
117
examines the value of the variable and sees how much it has
118
changed. The idler the system, the more it will have incremented. From
119
this it is simple to determine the load of the system.
120
121
122
The function cyg_cpuload_calibrate executes the
123
idle thread for 100ms to determine how much
124
idle_thread_loops is incremented on a system idle
125
for 100ms. cyg_cpuload_create starts an alarm which
126
every 100ms calls an alarm function. This function looks at the
127
difference in idle_thread_loops since the last
128
invocation of the alarm function and so calculated how idle or busy
129
the system has been. The structure cyg_cpuload is
130
updated during the alarm functions with the new results.  The 100ms
131
result is simply the result from the last measurement period. A simple
132
filter is used to average the load over a period of time, namely 1s
133
and 10s. Due to rounding errors, the 1s and 10s value will probably
134
never reach 100% on a fully loaded system, but 99% is often seen.
135
136
137
As stated above, clever power management code will interfere with
138
these measurements. The basic assumption is that the idle thread will
139
be executed un-hindered and under the same conditions as when the
140
calibration function was executed. If the CPU clock rate is reduced,
141
the idle thread counter will be incremented less and so the CPU load
142
measurements will give values too high. If the CPU is halted entirely,
143
100% cpu load will be measured.
144
145
146
147
148
149
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.