@@ -29,7 +29,9 | |||||
29 |
|
29 | |||
30 | unsigned char lfr_rtems_cpu_usage_report( void ); |
|
30 | unsigned char lfr_rtems_cpu_usage_report( void ); | |
31 |
|
31 | |||
|
32 | #define CONST_10 10 | |||
32 | #define CONST_100 100 |
|
33 | #define CONST_100 100 | |
|
34 | #define CONST_255 255 | |||
33 | #define CONST_1000 1000 |
|
35 | #define CONST_1000 1000 | |
34 | #define CONST_100000 100000 |
|
36 | #define CONST_100000 100000 | |
35 |
|
37 |
@@ -64,7 +64,7 option(FSW_debug_tch "?" OFF) | |||||
64 | set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE) |
|
64 | set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE) | |
65 | set(SW_VERSION_N2 "2" CACHE STRING "Choose N2 FSW Version." FORCE) |
|
65 | set(SW_VERSION_N2 "2" CACHE STRING "Choose N2 FSW Version." FORCE) | |
66 | set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE) |
|
66 | set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE) | |
67 |
set(SW_VERSION_N4 "1 |
|
67 | set(SW_VERSION_N4 "19" CACHE STRING "Choose N4 FSW Version." FORCE) | |
68 |
|
68 | |||
69 | if(FSW_verbose) |
|
69 | if(FSW_verbose) | |
70 | add_definitions(-DPRINT_MESSAGES_ON_CONSOLE) |
|
70 | add_definitions(-DPRINT_MESSAGES_ON_CONSOLE) |
@@ -816,7 +816,7 void get_cpu_load( unsigned char *resour | |||||
816 | old_avg_pos %= LOAD_AVG_SIZE; |
|
816 | old_avg_pos %= LOAD_AVG_SIZE; | |
817 | // CPU_LOAD_AVE |
|
817 | // CPU_LOAD_AVE | |
818 | resource_statistics[BYTE_2] = (unsigned char)(cpu_load_avg / LOAD_AVG_SIZE); |
|
818 | resource_statistics[BYTE_2] = (unsigned char)(cpu_load_avg / LOAD_AVG_SIZE); | |
819 |
|
819 | // this will change the way LFR compute usage | ||
820 | #ifndef PRINT_TASK_STATISTICS |
|
820 | #ifndef PRINT_TASK_STATISTICS | |
821 | rtems_cpu_usage_reset(); |
|
821 | rtems_cpu_usage_reset(); | |
822 | #endif |
|
822 | #endif |
@@ -28,11 +28,7 unsigned char lfr_rtems_cpu_usage_report | |||||
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 | Timestamp_Control abs_total; |
|
|||
32 | Timestamp_Control abs_ran; |
|
|||
33 |
|
31 | |||
34 | static Timestamp_Control last_total={0,0}; |
|
|||
35 | static Timestamp_Control last_ran={0,0}; |
|
|||
36 | #else |
|
32 | #else | |
37 | #error "Can't compute CPU usage using ticks on LFR" |
|
33 | #error "Can't compute CPU usage using ticks on LFR" | |
38 | #endif |
|
34 | #endif | |
@@ -42,8 +38,6 unsigned char lfr_rtems_cpu_usage_report | |||||
42 | ival = 0; |
|
38 | ival = 0; | |
43 | cpu_load = 0; |
|
39 | cpu_load = 0; | |
44 |
|
40 | |||
45 | _TOD_Get_uptime( &uptime ); |
|
|||
46 | _Timestamp_Subtract( &CPU_usage_Uptime_at_last_reset, &uptime, &abs_total ); |
|
|||
47 | for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) |
|
41 | for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) | |
48 | { |
|
42 | { | |
49 | if ( !_Objects_Information_table[ api_index ] ) { } |
|
43 | if ( !_Objects_Information_table[ api_index ] ) { } | |
@@ -59,30 +53,11 unsigned char lfr_rtems_cpu_usage_report | |||||
59 | if ( the_thread == NULL) { } |
|
53 | if ( the_thread == NULL) { } | |
60 | 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 | |
61 | { |
|
55 | { | |
62 |
|
|
56 | _TOD_Get_uptime( &uptime ); | |
63 | * If this is the currently executing thread, account for time |
|
57 | _Timestamp_Subtract( &CPU_usage_Uptime_at_last_reset, &uptime, &total ); | |
64 | * since the last context switch. |
|
58 | ran = the_thread->cpu_time_used; | |
65 | */ |
|
|||
66 | abs_ran = the_thread->cpu_time_used; |
|
|||
67 | if ( _Thread_Executing->Object.id == the_thread->Object.id ) |
|
|||
68 | { |
|
|||
69 | Timestamp_Control used; |
|
|||
70 | _Timestamp_Subtract( |
|
|||
71 | &_Thread_Time_of_last_context_switch, &uptime, &used |
|
|||
72 | ); |
|
|||
73 | _Timestamp_Add_to( &abs_ran, &used ); |
|
|||
74 | } |
|
|||
75 | /* |
|
|||
76 | * Only consider the time since last call |
|
|||
77 | */ |
|
|||
78 | _Timespec_Subtract(&last_ran, &abs_ran, &ran); |
|
|||
79 | _Timespec_Subtract(&last_total, &abs_total, &total); |
|
|||
80 |
|
||||
81 | last_ran = abs_ran; |
|
|||
82 | last_total = abs_total; |
|
|||
83 |
|
||||
84 | _Timestamp_Divide( &ran, &total, &ival, &fval); |
|
59 | _Timestamp_Divide( &ran, &total, &ival, &fval); | |
85 |
cpu_load = (unsigned char)(CONST_ |
|
60 | cpu_load = (unsigned char)(CONST_255 - ((ival*CONST_10+fval/CONST_100)*CONST_256/CONST_1000)); | |
86 | } |
|
61 | } | |
87 | } |
|
62 | } | |
88 | } |
|
63 | } |
General Comments 0
You need to be logged in to leave comments.
Login now