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/ratemonperiod.c | |
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/ratemonperiod.c')
-rw-r--r-- | cpukit/rtems/src/ratemonperiod.c | 77 |
1 files changed, 74 insertions, 3 deletions
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; |