summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/ratemongetstatus.c
diff options
context:
space:
mode:
authorGlenn Humphrey <glenn.humphrey@oarcorp.com>2009-12-08 23:05:30 +0000
committerGlenn Humphrey <glenn.humphrey@oarcorp.com>2009-12-08 23:05:30 +0000
commiteb37f9dc5d00c381717376d0dfd00ce86107b3a0 (patch)
treeea4a8a8ee303c9787fbd6f2172093ba0ee54f315 /cpukit/rtems/src/ratemongetstatus.c
parent2009-12-08 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-eb37f9dc5d00c381717376d0dfd00ce86107b3a0.tar.bz2
2009-12-08 Glenn Humphrey <glenn.humphrey@OARcorp.com>
* 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.
Diffstat (limited to 'cpukit/rtems/src/ratemongetstatus.c')
-rw-r--r--cpukit/rtems/src/ratemongetstatus.c40
1 files changed, 23 insertions, 17 deletions
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
}