@@ -1,2 +1,2 | |||
|
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters | |
|
1 | 29f7f58cbebc19532376c16541841ac4cb5f234c LFR_basic-parameters | |
|
2 | 2 | f5b83fb540b1cfd5d87c68621fb53f238eb623ae header/lfr_common_headers |
@@ -1,69 +1,69 | |||
|
1 | 1 | /* |
|
2 | 2 | * CPU Usage Reporter |
|
3 | 3 | * |
|
4 | 4 | * COPYRIGHT (c) 1989-2009 |
|
5 | 5 | * On-Line Applications Research Corporation (OAR). |
|
6 | 6 | * |
|
7 | 7 | * The license and distribution terms for this file may be |
|
8 | 8 | * found in the file LICENSE in this distribution or at |
|
9 | 9 | * http://www.rtems.com/license/LICENSE. |
|
10 | 10 | * |
|
11 | 11 | * $Id$ |
|
12 | 12 | */ |
|
13 | 13 | |
|
14 | 14 | #include "lfr_cpu_usage_report.h" |
|
15 | 15 | #include "fsw_params.h" |
|
16 | 16 | |
|
17 | 17 | extern rtems_id Task_id[]; |
|
18 | 18 | |
|
19 | 19 | unsigned char lfr_rtems_cpu_usage_report( void ) |
|
20 | 20 | { |
|
21 | 21 | uint32_t api_index; |
|
22 | 22 | uint32_t information_index; |
|
23 | 23 | Thread_Control *the_thread; |
|
24 | 24 | Objects_Information *information; |
|
25 | 25 | uint32_t ival; |
|
26 | 26 | uint32_t fval; |
|
27 | 27 | #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ |
|
28 | 28 | Timestamp_Control uptime; |
|
29 | 29 | Timestamp_Control total; |
|
30 | 30 | Timestamp_Control ran; |
|
31 | 31 | |
|
32 | 32 | #else |
|
33 | 33 | #error "Can't compute CPU usage using ticks on LFR" |
|
34 | 34 | #endif |
|
35 | 35 | |
|
36 | 36 | unsigned char cpu_load; |
|
37 | 37 | |
|
38 | 38 | ival = 0; |
|
39 | 39 | cpu_load = 0; |
|
40 | 40 | |
|
41 | 41 | for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) |
|
42 | 42 | { |
|
43 | 43 | if ( !_Objects_Information_table[ api_index ] ) { } |
|
44 | 44 | else |
|
45 | 45 | { |
|
46 | 46 | information = _Objects_Information_table[ api_index ][ 1 ]; |
|
47 | 47 | if ( information != NULL ) |
|
48 | 48 | { |
|
49 | 49 | for(information_index=1;information_index<=information->maximum;information_index++) |
|
50 | 50 | { |
|
51 | 51 | the_thread = (Thread_Control *)information->local_table[ information_index ]; |
|
52 | 52 | |
|
53 | 53 | if ( the_thread == NULL) { } |
|
54 | 54 | else if(the_thread->Object.id == Task_id[TASKID_SCRB]) // Only measure scrubbing task load, CPU load is 100%-Scrubbing |
|
55 | 55 | { |
|
56 | 56 | _TOD_Get_uptime( &uptime ); |
|
57 | 57 | _Timestamp_Subtract( &CPU_usage_Uptime_at_last_reset, &uptime, &total ); |
|
58 | 58 | ran = the_thread->cpu_time_used; |
|
59 | 59 | _Timestamp_Divide( &ran, &total, &ival, &fval); |
|
60 | cpu_load = (unsigned char)(CONST_255 - ((ival*CONST_10+fval/CONST_100)*CONST_256/CONST_1000)); | |
|
60 | cpu_load = (unsigned char) (CONST_255 - ((((ival*CONST_10) + (fval/CONST_100))*CONST_256)/CONST_1000)); | |
|
61 | 61 | } |
|
62 | 62 | } |
|
63 | 63 | } |
|
64 | 64 | } |
|
65 | 65 | } |
|
66 | 66 | return cpu_load; |
|
67 | 67 | } |
|
68 | 68 | |
|
69 | 69 |
General Comments 0
You need to be logged in to leave comments.
Login now