summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/ratemongetstatus.c
diff options
context:
space:
mode:
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
}