diff options
Diffstat (limited to 'cpukit/rtems')
-rw-r--r-- | cpukit/rtems/include/rtems/rtems/ratemon.h | 59 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemongetstatus.c | 12 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemonperiod.c | 47 |
3 files changed, 45 insertions, 73 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/ratemon.h b/cpukit/rtems/include/rtems/rtems/ratemon.h index 038c26e31e..3f990f28bd 100644 --- a/cpukit/rtems/include/rtems/rtems/ratemon.h +++ b/cpukit/rtems/include/rtems/rtems/ratemon.h @@ -62,6 +62,11 @@ extern "C" { * is used. */ #define RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS + + typedef struct timespec rtems_rate_monotonic_period_time_t; + +#else + typedef uint32_t rtems_rate_monotonic_period_time_t; #endif #include <rtems/score/object.h> @@ -72,6 +77,7 @@ extern "C" { #include <string.h> + /** * The following enumerated type defines the states in which a * period may be. @@ -98,42 +104,23 @@ typedef enum { typedef struct { uint32_t count; uint32_t missed_count; - #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS - struct timespec min_cpu_time; - struct timespec max_cpu_time; - struct timespec total_cpu_time; - #else - uint32_t min_cpu_time; - uint32_t max_cpu_time; - uint32_t total_cpu_time; - #endif - #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS - struct timespec min_wall_time; - struct timespec max_wall_time; - struct timespec total_wall_time; - #else - uint32_t min_wall_time; - uint32_t max_wall_time; - uint32_t total_wall_time; - #endif + RTEMS_CPU_USAGE_STATISTICS_TIME_TYPE min_cpu_time; + RTEMS_CPU_USAGE_STATISTICS_TIME_TYPE max_cpu_time; + RTEMS_CPU_USAGE_STATISTICS_TIME_TYPE total_cpu_time; + + rtems_rate_monotonic_period_time_t min_wall_time; + rtems_rate_monotonic_period_time_t max_wall_time; + rtems_rate_monotonic_period_time_t total_wall_time; } rtems_rate_monotonic_period_statistics; /** * The following defines the period status structure. */ typedef struct { - Objects_Id owner; - rtems_rate_monotonic_period_states state; - #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS - struct timespec since_last_period; - #else - uint32_t ticks_since_last_period; - #endif - #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS - struct timespec executed_since_last_period; - #else - uint32_t ticks_executed_since_last_period; - #endif + Objects_Id owner; + rtems_rate_monotonic_period_states state; + rtems_rate_monotonic_period_time_t since_last_period; + RTEMS_CPU_USAGE_STATISTICS_TIME_TYPE executed_since_last_period; } rtems_rate_monotonic_period_status; /** @@ -144,16 +131,8 @@ typedef struct { Objects_Control Object; Watchdog_Control Timer; rtems_rate_monotonic_period_states state; - #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS - struct timespec owner_executed_at_period; - #else - uint32_t owner_ticks_executed_at_period; - #endif - #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS - struct timespec time_at_period; - #else - uint32_t time_at_period; - #endif + RTEMS_CPU_USAGE_STATISTICS_TIME_TYPE owner_executed_at_period; + rtems_rate_monotonic_period_time_t time_at_period; uint32_t next_length; Thread_Control *owner; rtems_rate_monotonic_period_statistics Statistics; diff --git a/cpukit/rtems/src/ratemongetstatus.c b/cpukit/rtems/src/ratemongetstatus.c index 5ea67f38e7..ef47a032e5 100644 --- a/cpukit/rtems/src/ratemongetstatus.c +++ b/cpukit/rtems/src/ratemongetstatus.c @@ -68,13 +68,13 @@ rtems_status_code rtems_rate_monotonic_get_status( status->since_last_period.tv_sec = 0; status->since_last_period.tv_nsec = 0; #else - status->ticks_since_last_period = 0; + status->since_last_period = 0; #endif #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS status->executed_since_last_period.tv_sec = 0; status->executed_since_last_period.tv_nsec = 0; #else - status->ticks_executed_since_last_period = 0; + status->executed_since_last_period = 0; #endif } else { /* @@ -94,7 +94,7 @@ rtems_status_code rtems_rate_monotonic_get_status( &status->since_last_period ); #else - status->ticks_since_last_period = + status->since_last_period = _Watchdog_Ticks_since_boot - the_period->time_at_period; #endif @@ -105,9 +105,9 @@ rtems_status_code rtems_rate_monotonic_get_status( &status->executed_since_last_period ); #else - status->ticks_executed_since_last_period = - the_period->owner->ticks_executed - - the_period->owner_ticks_executed_at_period; + status->executed_since_last_period = + the_period->owner->cpu_time_used - + the_period->owner_executed_at_period; #endif } diff --git a/cpukit/rtems/src/ratemonperiod.c b/cpukit/rtems/src/ratemonperiod.c index ce32c796f3..3777b5ed76 100644 --- a/cpukit/rtems/src/ratemonperiod.c +++ b/cpukit/rtems/src/ratemonperiod.c @@ -33,16 +33,10 @@ void _Rate_monotonic_Update_statistics( ) { rtems_rate_monotonic_period_statistics *stats; - #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS - struct timespec executed; - #else - uint32_t ticks_executed_since_last_period; - #endif + RTEMS_CPU_USAGE_STATISTICS_TIME_TYPE executed; + rtems_rate_monotonic_period_time_t since_last_period; #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS - struct timespec period_start; - struct timespec since_last_period; - #else - uint32_t ticks_since_last_period; + rtems_rate_monotonic_period_time_t period_start; #endif #if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \ defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS) @@ -69,14 +63,13 @@ void _Rate_monotonic_Update_statistics( _Timespec_Subtract( &period_start, &uptime, &since_last_period ); the_period->time_at_period = uptime; #else - ticks_since_last_period = - _Watchdog_Ticks_since_boot - the_period->time_at_period; + since_last_period = _Watchdog_Ticks_since_boot - the_period->time_at_period; the_period->time_at_period = _Watchdog_Ticks_since_boot; #endif #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS { - struct timespec ran, used; + rtems_rate_monotonic_period_time_t ran, used; /* Grab CPU usage when the thread got switched in */ used = _Thread_Executing->cpu_time_used; @@ -95,8 +88,8 @@ void _Rate_monotonic_Update_statistics( ); } #else - ticks_executed_since_last_period = the_period->owner->ticks_executed - - the_period->owner_ticks_executed_at_period; + executed = the_period->owner->cpu_time_used - + the_period->owner_executed_at_period; #endif /* @@ -123,13 +116,13 @@ void _Rate_monotonic_Update_statistics( if ( _Timespec_Greater_than( &executed, &stats->max_cpu_time ) ) stats->max_cpu_time = executed; #else - stats->total_cpu_time += ticks_executed_since_last_period; + stats->total_cpu_time += executed; - if ( ticks_executed_since_last_period < stats->min_cpu_time ) - stats->min_cpu_time = ticks_executed_since_last_period; + if ( executed < stats->min_cpu_time ) + stats->min_cpu_time = executed; - if ( ticks_executed_since_last_period > stats->max_cpu_time ) - stats->max_cpu_time = ticks_executed_since_last_period; + if ( executed > stats->max_cpu_time ) + stats->max_cpu_time = executed; #endif /* @@ -137,13 +130,13 @@ void _Rate_monotonic_Update_statistics( */ #ifndef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS - stats->total_wall_time += ticks_since_last_period; + stats->total_wall_time += since_last_period; - if ( ticks_since_last_period < stats->min_wall_time ) - stats->min_wall_time = ticks_since_last_period; + if ( since_last_period < stats->min_wall_time ) + stats->min_wall_time = since_last_period; - if ( ticks_since_last_period > stats->max_wall_time ) - stats->max_wall_time = ticks_since_last_period; + if ( since_last_period > stats->max_wall_time ) + stats->max_wall_time = since_last_period; #else _Timespec_Add_to( &stats->total_wall_time, &since_last_period ); @@ -241,7 +234,7 @@ rtems_status_code rtems_rate_monotonic_period( #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS { - struct timespec ran; + RTEMS_CPU_USAGE_STATISTICS_TIME_TYPE ran; the_period->owner_executed_at_period = _Thread_Executing->cpu_time_used; @@ -260,8 +253,8 @@ rtems_status_code rtems_rate_monotonic_period( _Timespec_Add_to( &the_period->owner_executed_at_period, &ran ); } #else - the_period->owner_ticks_executed_at_period = - _Thread_Executing->ticks_executed; + the_period->owner_executed_at_period = + _Thread_Executing->cpu_time_used; #endif the_period->state = RATE_MONOTONIC_ACTIVE; |