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