diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-05-15 20:16:16 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-05-15 20:16:16 +0000 |
commit | e1bce866cf503c34f2914b76c9978bc598096013 (patch) | |
tree | d2419a46c38bc4d0eed2eaee219ec946de075596 /cpukit/rtems/src | |
parent | 2007-05-15 Ray Xu <rayx@gmail.com> (diff) | |
download | rtems-e1bce866cf503c34f2914b76c9978bc598096013.tar.bz2 |
2007-05-15 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, preinstall.am, libmisc/Makefile.am, rtems/Makefile.am,
rtems/include/rtems.h, rtems/include/rtems/rtems/ratemon.h,
rtems/inline/rtems/rtems/ratemon.inl, rtems/src/ratemoncancel.c,
rtems/src/ratemoncreate.c, rtems/src/ratemondelete.c,
rtems/src/ratemongetstatus.c, rtems/src/ratemonident.c,
rtems/src/ratemonperiod.c, rtems/src/ratemontimeout.c,
score/Makefile.am, score/include/rtems/score/object.h,
score/src/threadhandler.c, wrapup/Makefile.am: Integrate Rate
Monotonic Statistics and Period Usage into Rate Monotonic Manager.
Added the following directives: rtems_rate_monotonic_get_statistics,
rtems_rate_monotonic_reset_statistics,
rtems_rate_montonic_reset_all_statistics,
rtems_rate_montonic_report_statistics, and rtems_object_get_name.
Obsoleted the rtems/rtmonuse.h file as a public interface.
* rtems/src/ratemongetstatistics.c,
rtems/src/ratemonreportstatistics.c, rtems/src/ratemonresetall.c,
rtems/src/ratemonresetstatistics.c, rtems/src/rtemsobjectgetname.c,
score/src/objectgetnameasstring.c: New files.
* libmisc/rtmonuse/rtmonuse.c, libmisc/rtmonuse/rtmonuse.h: Removed.
Diffstat (limited to 'cpukit/rtems/src')
-rw-r--r-- | cpukit/rtems/src/ratemoncancel.c | 5 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemoncreate.c | 7 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemondelete.c | 5 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemongetstatistics.c | 71 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemongetstatus.c | 6 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemonident.c | 5 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemonperiod.c | 77 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemonreportstatistics.c | 90 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemonresetall.c | 56 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemonresetstatistics.c | 66 | ||||
-rw-r--r-- | cpukit/rtems/src/ratemontimeout.c | 5 | ||||
-rw-r--r-- | cpukit/rtems/src/rtemsobjectgetname.c | 34 |
12 files changed, 406 insertions, 21 deletions
diff --git a/cpukit/rtems/src/ratemoncancel.c b/cpukit/rtems/src/ratemoncancel.c index 254a1f51f9..fff77eb448 100644 --- a/cpukit/rtems/src/ratemoncancel.c +++ b/cpukit/rtems/src/ratemoncancel.c @@ -1,8 +1,7 @@ /* - * Rate Monotonic Manager + * Rate Monotonic Manager -- Cancel a Period * - * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be diff --git a/cpukit/rtems/src/ratemoncreate.c b/cpukit/rtems/src/ratemoncreate.c index 5585a8ea36..01dffcca58 100644 --- a/cpukit/rtems/src/ratemoncreate.c +++ b/cpukit/rtems/src/ratemoncreate.c @@ -1,8 +1,7 @@ /* - * Rate Monotonic Manager + * Rate Monotonic Manager -- Create a Period * - * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -68,6 +67,8 @@ rtems_status_code rtems_rate_monotonic_create( _Watchdog_Initialize( &the_period->Timer, NULL, 0, NULL ); + _Rate_monotonic_Reset_statistics( the_period ); + _Objects_Open( &_Rate_monotonic_Information, &the_period->Object, diff --git a/cpukit/rtems/src/ratemondelete.c b/cpukit/rtems/src/ratemondelete.c index b49311acbb..7eeabb2415 100644 --- a/cpukit/rtems/src/ratemondelete.c +++ b/cpukit/rtems/src/ratemondelete.c @@ -1,8 +1,7 @@ /* - * Rate Monotonic Manager + * Rate Monotonic Manager -- Delete a Period * - * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be diff --git a/cpukit/rtems/src/ratemongetstatistics.c b/cpukit/rtems/src/ratemongetstatistics.c new file mode 100644 index 0000000000..aae74b0328 --- /dev/null +++ b/cpukit/rtems/src/ratemongetstatistics.c @@ -0,0 +1,71 @@ +/* + * Rate Monotonic Manager -- Get Statistics + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/rtems/status.h> +#include <rtems/rtems/support.h> +#include <rtems/score/isr.h> +#include <rtems/score/object.h> +#include <rtems/rtems/ratemon.h> +#include <rtems/score/thread.h> + +/*PAGE + * + * rtems_rate_monotonic_get_statistics + * + * This directive allows a thread to obtain statistics information on a + * period. + * + * Input parameters: + * id - rate monotonic id + * statistics - pointer to statistics control block + * + * Output parameters: + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + * + */ + +rtems_status_code rtems_rate_monotonic_get_statistics( + Objects_Id id, + rtems_rate_monotonic_period_statistics *statistics +) +{ + Objects_Locations location; + Rate_monotonic_Control *the_period; + + if ( !statistics ) + return RTEMS_INVALID_ADDRESS; + + the_period = _Rate_monotonic_Get( id, &location ); + switch ( location ) { + case OBJECTS_REMOTE: /* should never return this */ + return RTEMS_INTERNAL_ERROR; + + case OBJECTS_ERROR: + return RTEMS_INVALID_ID; + + case OBJECTS_LOCAL: + + *statistics = the_period->Statistics; + + _Thread_Enable_dispatch(); + return RTEMS_SUCCESSFUL; + } + + return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ +} diff --git a/cpukit/rtems/src/ratemongetstatus.c b/cpukit/rtems/src/ratemongetstatus.c index e6363a7a71..d059e1ae3b 100644 --- a/cpukit/rtems/src/ratemongetstatus.c +++ b/cpukit/rtems/src/ratemongetstatus.c @@ -1,8 +1,7 @@ /* - * Rate Monotonic Manager + * Rate Monotonic Manager -- Get Status * - * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -61,6 +60,7 @@ rtems_status_code rtems_rate_monotonic_get_status( return RTEMS_INVALID_ID; case OBJECTS_LOCAL: + status->owner = ((the_period->owner) ? the_period->owner->Object.id : 0); status->state = the_period->state; if ( status->state == RATE_MONOTONIC_INACTIVE ) { diff --git a/cpukit/rtems/src/ratemonident.c b/cpukit/rtems/src/ratemonident.c index b81b92042e..bfe7ad4148 100644 --- a/cpukit/rtems/src/ratemonident.c +++ b/cpukit/rtems/src/ratemonident.c @@ -1,8 +1,7 @@ /* - * Rate Monotonic Manager + * Rate Monotonic Manager -- Name to Id Lookup * - * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be diff --git a/cpukit/rtems/src/ratemonperiod.c b/cpukit/rtems/src/ratemonperiod.c index e722c41ca7..83ae0e040d 100644 --- a/cpukit/rtems/src/ratemonperiod.c +++ b/cpukit/rtems/src/ratemonperiod.c @@ -1,8 +1,7 @@ /* - * Rate Monotonic Manager + * Rate Monotonic Manager - Period Blocking and Status * - * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -24,6 +23,61 @@ #include <rtems/rtems/ratemon.h> #include <rtems/score/thread.h> +void _Rate_monotonic_Update_statistics( + Rate_monotonic_Control *the_period +) +{ + uint32_t ticks_since_last_period; + uint32_t ticks_executed_since_last_period; + + /* + * Assume we are only called in states where it is appropriate + * to update the statistics. This should only be RATE_MONOTONIC_ACTIVE + * and RATE_MONOTONIC_EXPIRED. + */ + + /* + * Grab basic information + */ + + ticks_since_last_period = + _Watchdog_Ticks_since_boot - the_period->time_at_period; + + ticks_executed_since_last_period = the_period->owner->ticks_executed - + the_period->owner_ticks_executed_at_period; + + /* + * Now update the statistics + */ + + the_period->Statistics.count++; + if ( the_period->state == RATE_MONOTONIC_EXPIRED ) + the_period->Statistics.missed_count++; + the_period->Statistics.total_cpu_time += ticks_executed_since_last_period; + the_period->Statistics.total_wall_time += ticks_since_last_period; + + /* + * Update CPU time + */ + + if ( ticks_executed_since_last_period < the_period->Statistics.min_cpu_time ) + the_period->Statistics.min_cpu_time = ticks_executed_since_last_period; + + if ( ticks_executed_since_last_period > the_period->Statistics.max_cpu_time ) + the_period->Statistics.max_cpu_time = ticks_executed_since_last_period; + + /* + * Update Wall time + */ + + if ( ticks_since_last_period < the_period->Statistics.min_wall_time ) + the_period->Statistics.min_wall_time = ticks_since_last_period; + + if ( ticks_since_last_period > the_period->Statistics.max_wall_time ) + the_period->Statistics.max_wall_time = ticks_since_last_period; +} + + /*PAGE * * rtems_rate_monotonic_period @@ -86,7 +140,12 @@ rtems_status_code rtems_rate_monotonic_period( _ISR_Disable( level ); switch ( the_period->state ) { case RATE_MONOTONIC_INACTIVE: + /* + * No need to update statistics -- there are not a period active + */ + _ISR_Enable( level ); + the_period->state = RATE_MONOTONIC_ACTIVE; _Watchdog_Initialize( &the_period->Timer, @@ -106,6 +165,12 @@ rtems_status_code rtems_rate_monotonic_period( return RTEMS_SUCCESSFUL; case RATE_MONOTONIC_ACTIVE: + + /* + * Update statistics from the concluding period + */ + _Rate_monotonic_Update_statistics( the_period ); + /* * This tells the _Rate_monotonic_Timeout that this task is * in the process of blocking on the period and that we @@ -143,7 +208,13 @@ rtems_status_code rtems_rate_monotonic_period( break; case RATE_MONOTONIC_EXPIRED: + /* + * Update statistics from the concluding period + */ + _Rate_monotonic_Update_statistics( the_period ); + _ISR_Enable( level ); + the_period->state = RATE_MONOTONIC_ACTIVE; the_period->owner_ticks_executed_at_period = _Thread_Executing->ticks_executed; diff --git a/cpukit/rtems/src/ratemonreportstatistics.c b/cpukit/rtems/src/ratemonreportstatistics.c new file mode 100644 index 0000000000..352bd1d946 --- /dev/null +++ b/cpukit/rtems/src/ratemonreportstatistics.c @@ -0,0 +1,90 @@ +/* + * Rate Monotonic Manager -- Report Statistics for All Periods + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems.h> +#include <stdlib.h> +#include <ctype.h> +#include <inttypes.h> + +#include <rtems/bspIo.h> + +/* + * This directive allows a thread to print the statistics information + * on ALL period instances which have non-zero counts using printk. + * + * The implementation of this directive straddles the fence between + * inside and outside of RTEMS. It is presented as part of the Manager + * but actually uses other services of the Manager. + */ +void rtems_rate_montonic_report_statistics( void ) +{ + rtems_status_code status; + rtems_id id; + rtems_rate_monotonic_period_statistics the_stats; + rtems_rate_monotonic_period_status the_status; + char name[5]; + uint32_t ival_cpu, fval_cpu; + uint32_t ival_wall, fval_wall; + + printk( + "Period information by period\n" + " ID OWNER PERIODS MISSED CPU TIME WALL TIME\n" + ); + + /* + * Cycle through all possible ids and try to report on each one. If it + * is a period that is inactive, we just get an error back. No big deal. + */ + for ( id=_Rate_monotonic_Information.minimum_id ; + id <= _Rate_monotonic_Information.maximum_id ; + id++ ) { + status = rtems_rate_monotonic_get_statistics( id, &the_stats ); + if ( status != RTEMS_SUCCESSFUL ) + continue; + + /* If the above passed, so should this but check it anyway */ + status = rtems_rate_monotonic_get_status( id, &the_status ); + if ( status != RTEMS_SUCCESSFUL ) + continue; + + if ( the_stats.count == 0 ) + continue; + + ival_cpu = the_stats.total_cpu_time * 100 / the_stats.count; + + name[ 0 ] = '\0'; + + if ( the_status.owner ) { + rtems_object_get_name( the_status.owner, sizeof(name), name ); + } + + fval_cpu = ival_cpu % 100; + ival_cpu /= 100; + ival_wall = the_stats.total_wall_time * 100 / the_stats.count; + fval_wall = ival_wall % 100; + ival_wall /= 100; + printk( + "0x%08" PRIx32 " %4s %6" PRId32 " %3" PRId32 " " + "%" PRId32 "/%" PRId32 "/%" PRId32 ".%02" PRId32 " " + "%" PRId32 "/%" PRId32 "/%" PRId32 ".%02" PRId32 "\n", + id, name, + the_stats.count, the_stats.missed_count, + the_stats.min_cpu_time, the_stats.max_cpu_time, ival_cpu, fval_cpu, + the_stats.min_wall_time, the_stats.max_wall_time, ival_wall, fval_wall + ); + } +} diff --git a/cpukit/rtems/src/ratemonresetall.c b/cpukit/rtems/src/ratemonresetall.c new file mode 100644 index 0000000000..8b91ddd3e5 --- /dev/null +++ b/cpukit/rtems/src/ratemonresetall.c @@ -0,0 +1,56 @@ +/* + * Rate Monotonic Manager -- Reset Statistics for All Periods + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/rtems/status.h> +#include <rtems/rtems/support.h> +#include <rtems/score/object.h> +#include <rtems/rtems/ratemon.h> +#include <rtems/score/thread.h> + +/* + * rtems_rate_montonic_reset_all_statistics + */ +void rtems_rate_montonic_reset_all_statistics( void ) +{ + Objects_Id id; + rtems_status_code status; + + /* + * Prevent allocation or deallocation of any of the periods while + * we are cycling. Also this is an optimization which ensures that + * we only disable/enable once. The call to + * rtems_rate_monotonic_reset_statistics will be in a nested dispatch + * disabled critical section. + */ + _Thread_Disable_dispatch(); + + /* + * Cycle through all possible ids and try to reset each one. If it + * is a period that is inactive, we just get an error back. No big deal. + */ + for ( id=_Rate_monotonic_Information.minimum_id ; + id <= _Rate_monotonic_Information.maximum_id ; + id++ ) { + status = rtems_rate_monotonic_reset_statistics( id ); + } + + /* + * Done so exit thread dispatching disabled critical section. + */ + _Thread_Enable_dispatch(); +} diff --git a/cpukit/rtems/src/ratemonresetstatistics.c b/cpukit/rtems/src/ratemonresetstatistics.c new file mode 100644 index 0000000000..6d8f9c5e11 --- /dev/null +++ b/cpukit/rtems/src/ratemonresetstatistics.c @@ -0,0 +1,66 @@ +/* + * Rate Monotonic Manager -- Reset Statistics + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/rtems/status.h> +#include <rtems/rtems/support.h> +#include <rtems/score/isr.h> +#include <rtems/score/object.h> +#include <rtems/rtems/ratemon.h> +#include <rtems/score/thread.h> + +/*PAGE + * + * rtems_rate_monotonic_reset_statistics + * + * This directive allows a thread to reset the statistics information + * on a specific period instance. + * + * Input parameters: + * id - rate monotonic id + * + * Output parameters: + * RTEMS_SUCCESSFUL - if successful + * error code - if unsuccessful + * + */ + +rtems_status_code rtems_rate_monotonic_reset_statistics( + Objects_Id id +) +{ + Objects_Locations location; + Rate_monotonic_Control *the_period; + + the_period = _Rate_monotonic_Get( id, &location ); + switch ( location ) { + case OBJECTS_REMOTE: /* should never return this */ + return RTEMS_INTERNAL_ERROR; + + case OBJECTS_ERROR: + return RTEMS_INVALID_ID; + + case OBJECTS_LOCAL: + + _Rate_monotonic_Reset_statistics( the_period ); + + _Thread_Enable_dispatch(); + return RTEMS_SUCCESSFUL; + } + + return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ +} diff --git a/cpukit/rtems/src/ratemontimeout.c b/cpukit/rtems/src/ratemontimeout.c index deb9a18bc6..3649d574d5 100644 --- a/cpukit/rtems/src/ratemontimeout.c +++ b/cpukit/rtems/src/ratemontimeout.c @@ -1,8 +1,7 @@ /* - * Rate Monotonic Manager + * Rate Monotonic Manager -- Period End Timeout Handler * - * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be diff --git a/cpukit/rtems/src/rtemsobjectgetname.c b/cpukit/rtems/src/rtemsobjectgetname.c new file mode 100644 index 0000000000..2fbf39425d --- /dev/null +++ b/cpukit/rtems/src/rtemsobjectgetname.c @@ -0,0 +1,34 @@ +/* + * RTEMS Object Helper -- Obtain Name of Object as String + * + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/score/object.h> + +/* + * This method objects the name of an object and returns its name + * in the form of a C string. It attempts to be careful about + * overflowing the user's string and about returning unprintable characters. + */ + +char *rtems_object_get_name( + Objects_Id id, + size_t length, + char *name +) +{ + return _Objects_Get_name_as_string( id, length, name ); +} |