From eb37f9dc5d00c381717376d0dfd00ce86107b3a0 Mon Sep 17 00:00:00 2001 From: Glenn Humphrey Date: Tue, 8 Dec 2009 23:05:30 +0000 Subject: 2009-12-08 Glenn Humphrey * rtems/include/rtems/rtems/ratemon.h, rtems/src/ratemongetstatus.c, rtems/src/ratemonperiod.c: Factored out common code to ensure consistent behavior between rtems_rate_monotonic_get_status and rtems_rate_monotonic_report_statistics. --- cpukit/rtems/src/ratemongetstatus.c | 40 +++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'cpukit/rtems/src/ratemongetstatus.c') diff --git a/cpukit/rtems/src/ratemongetstatus.c b/cpukit/rtems/src/ratemongetstatus.c index bb22254563..5cc6b56a5e 100644 --- a/cpukit/rtems/src/ratemongetstatus.c +++ b/cpukit/rtems/src/ratemongetstatus.c @@ -49,12 +49,11 @@ rtems_status_code rtems_rate_monotonic_get_status( rtems_rate_monotonic_period_status *status ) { + Thread_CPU_usage_t executed; Objects_Locations location; + Rate_monotonic_Period_time_t since_last_period; Rate_monotonic_Control *the_period; - #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ - Timestamp_Control uptime; - Timestamp_Control temp; - #endif + bool valid_status; if ( !status ) return RTEMS_INVALID_ADDRESS; @@ -79,22 +78,29 @@ rtems_status_code rtems_rate_monotonic_get_status( #endif } else { + + /* + * Grab the current status. + */ + valid_status = + _Rate_monotonic_Get_status( + the_period, &since_last_period, &executed + ); + if (!valid_status) { + _Thread_Enable_dispatch(); + return RTEMS_NOT_DEFINED; + } + #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ - _TOD_Get_uptime( &uptime ); - _Timestamp_Subtract( &the_period->time_at_period, &uptime, &temp ); - _Timestamp_To_timespec( &temp, &status->since_last_period ); - _Timestamp_Subtract( - &_Thread_Time_of_last_context_switch, - &uptime, - &temp + _Timestamp_To_timespec( + &since_last_period, &status->since_last_period + ); + _Timestamp_To_timespec( + &executed, &status->executed_since_last_period ); - _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; + status->since_last_period = since_last_period; + status->executed_since_last_period = executed; #endif } -- cgit v1.2.3