From c6f7e060eaeb951a86dc640855e88c6f8260a347 Mon Sep 17 00:00:00 2001 From: Glenn Humphrey Date: Wed, 2 Dec 2009 18:15:16 +0000 Subject: 2009-12-02 Glenn Humphrey * configure.ac, libcsupport/src/__times.c, libmisc/cpuuse/cpuusagedata.c, libmisc/cpuuse/cpuusagereport.c, libmisc/cpuuse/cpuusagereset.c, rtems/include/rtems/rtems/ratemon.h, rtems/include/rtems/rtems/types.h, rtems/src/ratemongetstatistics.c, rtems/src/ratemongetstatus.c, rtems/src/ratemonperiod.c, rtems/src/ratemonreportstatistics.c, score/include/rtems/score/thread.h, score/src/threaddispatch.c, score/src/threadinitialize.c, score/src/threadtickletimeslice.c: Changed the configuration of statistics granularity to use just one define. --- cpukit/rtems/include/rtems/rtems/ratemon.h | 22 ++--------- cpukit/rtems/include/rtems/rtems/types.h | 5 +-- cpukit/rtems/src/ratemongetstatistics.c | 12 ++---- cpukit/rtems/src/ratemongetstatus.c | 35 ++++++----------- cpukit/rtems/src/ratemonperiod.c | 61 ++++++++++++++---------------- cpukit/rtems/src/ratemonreportstatistics.c | 29 +++++--------- 6 files changed, 59 insertions(+), 105 deletions(-) (limited to 'cpukit/rtems') diff --git a/cpukit/rtems/include/rtems/rtems/ratemon.h b/cpukit/rtems/include/rtems/rtems/ratemon.h index 20cccc5d46..04f45d29a6 100644 --- a/cpukit/rtems/include/rtems/rtems/ratemon.h +++ b/cpukit/rtems/include/rtems/rtems/ratemon.h @@ -54,25 +54,11 @@ extern "C" { #endif -/* - * The user can define this at configure time and go back to ticks - * resolution. - */ -#if !defined(__RTEMS_USE_TICKS_RATE_MONOTONIC_STATISTICS__) - /** - * Enable the nanosecond accurate statistics - * - * When not defined, the older style tick accurate granularity - * is used. - */ - #define RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS -#endif - /** * This is the public type used for the rate monotonic timing * statistics. */ -#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ #include typedef struct timespec rtems_rate_monotonic_period_time_t; @@ -84,7 +70,7 @@ extern "C" { * This is the internal type used for the rate monotonic timing * statistics. */ -#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ #include typedef Timestamp_Control Rate_monotonic_Period_time_t; @@ -435,7 +421,7 @@ void _Rate_monotonic_Initiate_statistics( * * This method resets the statistics information for a period instance. */ -#ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ #define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \ do { \ /* set the minimums to a large value */ \ @@ -458,7 +444,7 @@ void _Rate_monotonic_Initiate_statistics( * * This helper method resets the period CPU usage statistics structure. */ -#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ #define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \ do { \ /* set the minimums to a large value */ \ diff --git a/cpukit/rtems/include/rtems/rtems/types.h b/cpukit/rtems/include/rtems/rtems/types.h index 4c867c5cf4..8d8e77fd9c 100644 --- a/cpukit/rtems/include/rtems/rtems/types.h +++ b/cpukit/rtems/include/rtems/rtems/types.h @@ -124,15 +124,14 @@ typedef Watchdog_Interval rtems_interval; * @brief Represents the CPU usage per thread. * * When using nano seconds granularity timing, RTEMS may internally use a - * variety of represenations. + * variety of representations. */ -#ifndef __RTEMS_USE_TICKS_CPU_USAGE_STATISTICS__ +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ typedef struct timespec rtems_thread_cpu_usage_t; #else typedef uint32_t rtems_thread_cpu_usage_t; #endif - /** * @brief Data structure to manage and manipulate calendar time. */ diff --git a/cpukit/rtems/src/ratemongetstatistics.c b/cpukit/rtems/src/ratemongetstatistics.c index 9b6eb4b173..611eb0d3c3 100644 --- a/cpukit/rtems/src/ratemongetstatistics.c +++ b/cpukit/rtems/src/ratemongetstatistics.c @@ -61,21 +61,17 @@ rtems_status_code rtems_rate_monotonic_get_statistics( src = &the_period->Statistics; dst->count = src->count; dst->missed_count = src->missed_count; - #if defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS) + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ _Timestamp_To_timespec( &src->min_cpu_time, &dst->min_cpu_time ); _Timestamp_To_timespec( &src->max_cpu_time, &dst->max_cpu_time ); _Timestamp_To_timespec( &src->total_cpu_time, &dst->total_cpu_time ); - #else - statistics->min_wall_time = src->min_wall_time; - statistics->max_wall_time = src->max_wall_time; - statistics->total_wall_time = src->total_wall_time; - #endif - - #if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) _Timestamp_To_timespec( &src->min_wall_time, &dst->min_wall_time ); _Timestamp_To_timespec( &src->max_wall_time, &dst->max_wall_time ); _Timestamp_To_timespec( &src->total_wall_time, &dst->total_wall_time ); #else + dst->min_cpu_time = src->min_cpu_time; + dst->max_cpu_time = src->max_cpu_time; + dst->total_cpu_time = src->total_cpu_time; dst->min_wall_time = src->min_wall_time; dst->max_wall_time = src->max_wall_time; dst->total_wall_time = src->total_wall_time; diff --git a/cpukit/rtems/src/ratemongetstatus.c b/cpukit/rtems/src/ratemongetstatus.c index 8fc003f7e4..bb22254563 100644 --- a/cpukit/rtems/src/ratemongetstatus.c +++ b/cpukit/rtems/src/ratemongetstatus.c @@ -23,8 +23,7 @@ #include #include -#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \ - defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS) +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ #include #endif @@ -52,8 +51,7 @@ rtems_status_code rtems_rate_monotonic_get_status( { Objects_Locations location; Rate_monotonic_Control *the_period; - #if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \ - defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS) + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ Timestamp_Control uptime; Timestamp_Control temp; #endif @@ -68,36 +66,23 @@ rtems_status_code rtems_rate_monotonic_get_status( status->owner = the_period->owner->Object.id; status->state = the_period->state; + /* + * If the period is inactive, there is no information. + */ if ( status->state == RATE_MONOTONIC_INACTIVE ) { - #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ _Timespec_Set_to_zero( &status->since_last_period ); - #else - status->since_last_period = 0; - #endif - #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS _Timespec_Set_to_zero( &status->executed_since_last_period ); #else + status->since_last_period = 0; status->executed_since_last_period = 0; #endif + } else { - /* - * Both nanoseconds granularity options have to know the uptime. - * This lets them share one single invocation of _TOD_Get_uptime(). - */ - #if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \ - defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS) + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ _TOD_Get_uptime( &uptime ); - #endif - - #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS _Timestamp_Subtract( &the_period->time_at_period, &uptime, &temp ); _Timestamp_To_timespec( &temp, &status->since_last_period ); - #else - status->since_last_period = - _Watchdog_Ticks_since_boot - the_period->time_at_period; - #endif - - #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS _Timestamp_Subtract( &_Thread_Time_of_last_context_switch, &uptime, @@ -105,6 +90,8 @@ rtems_status_code rtems_rate_monotonic_get_status( ); _Timestamp_To_timespec( &temp, &status->executed_since_last_period ); #else + status->since_last_period = + _Watchdog_Ticks_since_boot - the_period->time_at_period; status->executed_since_last_period = the_period->owner->cpu_time_used - the_period->owner_executed_at_period; diff --git a/cpukit/rtems/src/ratemonperiod.c b/cpukit/rtems/src/ratemonperiod.c index 9d2ed6006a..a09de1d3e2 100644 --- a/cpukit/rtems/src/ratemonperiod.c +++ b/cpukit/rtems/src/ratemonperiod.c @@ -30,13 +30,10 @@ void _Rate_monotonic_Initiate_statistics( Thread_Control *owning_thread = the_period->owner; /* - * If any statistics are at nanosecond granularity, we need to - * obtain the uptime. + * If using nanosecond statistics, we need to obtain the uptime. */ - #if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \ - defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS) - - struct timespec uptime; + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + Timestamp_Control uptime; _TOD_Get_uptime( &uptime ); #endif @@ -44,7 +41,7 @@ void _Rate_monotonic_Initiate_statistics( /* * Set the starting point and the CPU time used for the statistics. */ - #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ the_period->time_at_period = uptime; #else the_period->time_at_period = _Watchdog_Ticks_since_boot; @@ -53,14 +50,14 @@ void _Rate_monotonic_Initiate_statistics( the_period->owner_executed_at_period = owning_thread->cpu_time_used; /* - * If using nanosecond granularity for CPU Usage Statistics and the - * period's thread is currently executing, then we need to take into - * account how much time the executing thread has run since the last - * context switch. When this routine is invoked from - * rtems_rate_monotonic_period, the owner will be the executing thread. - * When this routine is invoked from _Rate_monotonic_Timeout, it will not. + * If using nanosecond statistics and the period's thread is currently + * executing, then we need to take into account how much time the + * executing thread has run since the last context switch. When this + * routine is invoked from rtems_rate_monotonic_period, the owner will + * be the executing thread. When this routine is invoked from + * _Rate_monotonic_Timeout, it will not. */ - #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ if (owning_thread == _Thread_Executing) { rtems_thread_cpu_usage_t ran; @@ -85,13 +82,13 @@ void _Rate_monotonic_Update_statistics( Rate_monotonic_Statistics *stats; Thread_CPU_usage_t executed; Rate_monotonic_Period_time_t since_last_period; - #if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \ - defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS) - Timestamp_Control uptime; - /* - * Obtain the current time since boot - */ + /* + * If using nanosecond statistics, we need to obtain the uptime. + */ + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + Timestamp_Control uptime; + _TOD_Get_uptime( &uptime ); #endif @@ -113,7 +110,7 @@ void _Rate_monotonic_Update_statistics( /* * Grab basic information for time statistics. */ - #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ _Timespec_Subtract( &the_period->time_at_period, &uptime, @@ -123,7 +120,7 @@ void _Rate_monotonic_Update_statistics( since_last_period = _Watchdog_Ticks_since_boot - the_period->time_at_period; #endif - #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ { Thread_CPU_usage_t ran, used; @@ -159,8 +156,7 @@ void _Rate_monotonic_Update_statistics( /* * Update CPU time */ - - #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ _Timestamp_Add_to( &stats->total_cpu_time, &executed ); if ( _Timestamp_Less_than( &executed, &stats->min_cpu_time ) ) @@ -181,8 +177,15 @@ void _Rate_monotonic_Update_statistics( /* * Update Wall time */ + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + _Timestamp_Add_to( &stats->total_wall_time, &since_last_period ); - #ifndef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS + if ( _Timestamp_Less_than( &since_last_period, &stats->min_wall_time ) ) + stats->min_wall_time = since_last_period; + + if ( _Timestamp_Greater_than( &since_last_period, &stats->max_wall_time ) ) + stats->max_wall_time = since_last_period; + #else /* Sanity check wall time */ if ( since_last_period < executed ) @@ -195,14 +198,6 @@ void _Rate_monotonic_Update_statistics( if ( since_last_period > stats->max_wall_time ) stats->max_wall_time = since_last_period; - #else - _Timestamp_Add_to( &stats->total_wall_time, &since_last_period ); - - if ( _Timestamp_Less_than( &since_last_period, &stats->min_wall_time ) ) - stats->min_wall_time = since_last_period; - - if ( _Timestamp_Greater_than( &since_last_period, &stats->max_wall_time ) ) - stats->max_wall_time = since_last_period; #endif } diff --git a/cpukit/rtems/src/ratemonreportstatistics.c b/cpukit/rtems/src/ratemonreportstatistics.c index 2aa5129bcc..791bb544ec 100644 --- a/cpukit/rtems/src/ratemonreportstatistics.c +++ b/cpukit/rtems/src/ratemonreportstatistics.c @@ -23,8 +23,7 @@ #include #include -#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \ - defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS) +#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ /* We print to 1/10's of milliseconds */ #define NANOSECONDS_DIVIDER 1000 #define PERCENT_FMT "%04" PRId32 @@ -54,10 +53,8 @@ void rtems_rate_monotonic_report_statistics_with_plugin( return; (*print)( context, "Period information by period\n" ); - #if defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS) + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ (*print)( context, "--- CPU times are in seconds ---\n" ); - #endif - #if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) (*print)( context, "--- Wall times are in seconds ---\n" ); #endif /* @@ -74,28 +71,22 @@ ididididid NNNN ccccc mmmmmm X \n"); */ (*print)( context, " ID OWNER COUNT MISSED " - #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ " " #endif "CPU TIME " - #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS - " " - #endif - #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS - " " + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + " " #endif " WALL TIME\n" ); (*print)( context, " " - #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ " " #endif "MIN/MAX/AVG " - #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS - " " - #endif - #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS - " " + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ + " " #endif " MIN/MAX/AVG\n" ); @@ -141,7 +132,7 @@ ididididid NNNN ccccc mmmmmm X * print CPU Usage part of statistics */ { - #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ struct timespec cpu_average; struct timespec *min_cpu = &the_stats.min_cpu_time; struct timespec *max_cpu = &the_stats.max_cpu_time; @@ -177,7 +168,7 @@ ididididid NNNN ccccc mmmmmm X * print wall time part of statistics */ { - #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ struct timespec wall_average; struct timespec *min_wall = &the_stats.min_wall_time; struct timespec *max_wall = &the_stats.max_wall_time; -- cgit v1.2.3