annotate packages/services/cpuload/current/src/cpuload.cxx @ 2729:74dbf4c3f2e1 after-copyright-change-20090129

Update all copyright banners to reflect FSF ownership; fix and improve licence text.
author jlarmour
date Thu, 29 Jan 2009 17:47:46 +0000
parents 7de36227e601
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
301
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
1 //==========================================================================
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
2 //
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
3 // cpuload.cxx
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
4 //
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
5 // Estimate the current CPU load.
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
6 //
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
7 //==========================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
8 // ####ECOSGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
9 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
301
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
12 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
13 // eCos is free software; you can redistribute it and/or modify it under
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
14 // the terms of the GNU General Public License as published by the Free
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
15 // Software Foundation; either version 2 or (at your option) any later
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
16 // version.
301
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
17 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
18 // eCos is distributed in the hope that it will be useful, but WITHOUT
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
21 // for more details.
301
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
22 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
23 // You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
24 // along with eCos; if not, write to the Free Software Foundation, Inc.,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
301
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
26 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
27 // As a special exception, if other files instantiate templates or use
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
28 // macros or inline functions from this file, or you compile this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
29 // and link it with other works to produce a work based on this file,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
30 // this file does not by itself cause the resulting work to be covered by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
31 // the GNU General Public License. However the source code for this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
32 // must still be made available in accordance with section (3) of the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
33 // General Public License v2.
301
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
34 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
35 // This exception does not invalidate any other reasons why a work based
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
36 // on this file might be covered by the GNU General Public License.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
37 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 301
diff changeset
38 // ####ECOSGPLCOPYRIGHTEND####
301
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
39 //==========================================================================
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
40 //#####DESCRIPTIONBEGIN####
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
41 //
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
42 // Author(s): Andrew Lunn
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
43 // Contributors: Andrew Lunn
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
44 // Date: 2002-08-12
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
45 // Purpose:
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
46 // Description:
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
47 // This provides a simple CPU load meter. All loads are returned
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
48 // as a percentage, ie 0-100. This is only a rough measure. Any clever
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
49 // power management, sleep modes etc, will cause these results to be
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
50 // wrong.
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
51 //
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
52 // This code is part of eCos (tm).
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
53 //
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
54 //####DESCRIPTIONEND####
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
55 //
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
56 //==========================================================================
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
57
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
58 #include <cyg/kernel/kapi.h>
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
59 #include <cyg/hal/hal_arch.h>
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
60 #include <cyg/cpuload/cpuload.h>
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
61
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
62 /* Here we run the idle thread as a high priority thread for 0.1
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
63 second. We see how much the counter in the idle loop is
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
64 incremented. This will only work if there are no other threads
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
65 running at priority 1 and 2 */
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
66
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
67 static cyg_thread thread;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
68 externC cyg_uint32 idle_thread_loops;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
69 char idle_stack[CYGNUM_HAL_STACK_SIZE_MINIMUM];
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
70
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
71 extern void idle_thread_main( CYG_ADDRESS data );
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
72
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
73 // -------------------------------------------------------------------------
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
74 /* We are playing ping-pong with the cpuload_calibrate function and
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
75 the idle thread. First cpuload_calibrate runs. Next the idle
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
76 thread, then this alarm function and then back to the
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
77 cpuload_calibrate function. */
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
78
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
79 void static
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
80 alarm_func(cyg_handle_t alarm,cyg_addrword_t data) {
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
81 cyg_handle_t idleH = (cyg_handle_t) data;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
82 cyg_thread_suspend(idleH);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
83 }
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
84
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
85
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
86 /* Calibrate the cpuload measurements.*/
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
87 externC void
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
88 cyg_cpuload_calibrate(cyg_uint32 *calibration) {
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
89 cyg_handle_t counter;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
90 cyg_alarm alarm_s;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
91 cyg_handle_t alarmH;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
92 cyg_uint32 idle_loops_start;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
93 cyg_handle_t idleH;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
94 cyg_priority_t old_priority;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
95
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
96 cyg_thread_create(1,
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
97 idle_thread_main,
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
98 0,
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
99 "Calibration idle thread",
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
100 idle_stack,
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
101 sizeof(idle_stack),
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
102 &idleH,
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
103 &thread);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
104
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
105 cyg_clock_to_counter(cyg_real_time_clock(),&counter);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
106 cyg_alarm_create(counter,alarm_func,(cyg_addrword_t)idleH,&alarmH,&alarm_s);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
107
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
108 cyg_alarm_initialize(alarmH,cyg_current_time()+10,0);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
109 cyg_alarm_enable(alarmH);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
110
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
111 idle_loops_start = idle_thread_loops;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
112
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
113 /* Dont be decieved, remember this is a multithreaded system ! */
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
114 old_priority = cyg_thread_get_priority(cyg_thread_self());
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
115 cyg_thread_set_priority(cyg_thread_self(),2);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
116 cyg_thread_resume(idleH);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
117 cyg_thread_set_priority(cyg_thread_self(),old_priority);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
118
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
119 *calibration = idle_thread_loops - idle_loops_start;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
120 cyg_alarm_delete(alarmH);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
121 cyg_thread_kill(idleH);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
122 cyg_thread_delete(idleH);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
123 }
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
124
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
125 static void
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
126 cpuload_alarm_func(cyg_handle_t alarm,cyg_addrword_t data) {
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
127 cyg_cpuload_t * cpuload = (cyg_cpuload_t *)data;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
128 cyg_uint32 idle_loops_now = idle_thread_loops;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
129 cyg_uint32 idle_loops;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
130 cyg_uint32 load;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
131
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
132 if (idle_loops_now >= cpuload->last_idle_loops) {
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
133 idle_loops = idle_loops_now - cpuload->last_idle_loops;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
134 } else {
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
135 idle_loops = ~0 - (cpuload->last_idle_loops - idle_loops_now);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
136 }
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
137
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
138 /* We need 64 bit arithmatic to prevent wrap around */
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
139 load = (cyg_uint32) (((cyg_uint64) idle_loops * (cyg_uint64)100) /
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
140 (cyg_uint64)cpuload->calibration);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
141 if (load > 100) {
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
142 load = 100;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
143 }
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
144 load = 100 - load;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
145
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
146 cpuload->average_point1s = load;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
147 cpuload->average_1s = load + ((cpuload->average_1s * 90)/100);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
148 cpuload->average_10s = load + ((cpuload->average_10s * 99)/100);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
149 cpuload->last_idle_loops = idle_loops_now;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
150 }
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
151
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
152 /* Create a CPU load measurements object and start the
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
153 measurements. */
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
154 externC void
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
155 cyg_cpuload_create(cyg_cpuload_t *cpuload,
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
156 cyg_uint32 calibration,
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
157 cyg_handle_t *handle)
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
158 {
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
159 cyg_handle_t counter;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
160
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
161 cpuload->average_point1s = 0;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
162 cpuload->average_1s = 0;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
163 cpuload->average_10s = 0;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
164 cpuload->calibration = calibration;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
165 cpuload->last_idle_loops = idle_thread_loops;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
166
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
167 cyg_clock_to_counter(cyg_real_time_clock(),&counter);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
168 cyg_alarm_create(counter,
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
169 cpuload_alarm_func,
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
170 (cyg_addrword_t)cpuload,
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
171 &cpuload->alarmH,
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
172 &cpuload->alarm_s);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
173
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
174 cyg_alarm_initialize(cpuload->alarmH,cyg_current_time()+10,10);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
175 cyg_alarm_enable(cpuload->alarmH);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
176
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
177 *handle = (cyg_handle_t) cpuload;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
178 }
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
179
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
180 /* Stop measurements of the cpuload. The cyg_cpuload_t object can then
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
181 be freed. */
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
182 externC void
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
183 cyg_cpuload_delete(cyg_handle_t handle) {
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
184 cyg_cpuload_t * cpuload = (cyg_cpuload_t *) handle;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
185
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
186 cyg_alarm_delete(cpuload->alarmH);
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
187 }
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
188
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
189 /* Return the cpuload for the last 100ms, 1seconds and 10 second */
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
190 externC void
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
191 cyg_cpuload_get(cyg_handle_t handle,
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
192 cyg_uint32 *average_point1s,
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
193 cyg_uint32 *average_1s,
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
194 cyg_uint32 *average_10s) {
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
195
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
196 cyg_cpuload_t * cpuload = (cyg_cpuload_t *) handle;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
197 *average_point1s = cpuload->average_point1s;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
198 *average_1s = cpuload->average_1s/10;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
199 *average_10s = cpuload->average_10s/100;
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
200 }
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
201
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
202
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
203
7de36227e601 * Created a new package with my CPU load measurement code which
asl
parents:
diff changeset
204