summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/ratemongetstatus.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-05-17 22:46:45 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-05-17 22:46:45 +0000
commitc3330a88ee5d674b09dded32ef1ccba26a9c3034 (patch)
treef7f247449fc18bc299ef695c3503f9b7790db97a /cpukit/rtems/src/ratemongetstatus.c
parentAdd .rh clause to extra_arg. (diff)
downloadrtems-c3330a88ee5d674b09dded32ef1ccba26a9c3034.tar.bz2
2007-05-17 Joel Sherrill <joel.sherrill@oarcorp.com>
* ChangeLog, configure.ac, libcsupport/src/__times.c, libmisc/cpuuse/cpuuse.c, libmisc/stackchk/check.c, rtems/include/rtems/rtems/ratemon.h, rtems/src/ratemongetstatus.c, rtems/src/ratemonperiod.c, rtems/src/ratemonreportstatistics.c, rtems/src/ratemonresetall.c, rtems/src/ratemontimeout.c, score/Makefile.am, score/include/rtems/score/thread.h, score/include/rtems/score/timespec.h, score/src/threaddispatch.c, score/src/threadinitialize.c, score/src/threadtickletimeslice.c, score/src/timespecdivide.c: Add nanoseconds granularity to the rate monotonic period statistics and CPU usage statistics. This capability is enabled by default although may be conditionally disabled by the user. It could be too much overhead on small targets but it does not appear to be bad in early testing. Its impact on code size has not been evaluated either. It is possible that both forms of statistics gathering could be disabled with further tweaking of the conditional compilation. * score/src/timespecdividebyinteger.c: New file.
Diffstat (limited to 'cpukit/rtems/src/ratemongetstatus.c')
-rw-r--r--cpukit/rtems/src/ratemongetstatus.c55
1 files changed, 48 insertions, 7 deletions
diff --git a/cpukit/rtems/src/ratemongetstatus.c b/cpukit/rtems/src/ratemongetstatus.c
index d059e1ae3b..d46b133e73 100644
--- a/cpukit/rtems/src/ratemongetstatus.c
+++ b/cpukit/rtems/src/ratemongetstatus.c
@@ -23,6 +23,11 @@
#include <rtems/rtems/ratemon.h>
#include <rtems/score/thread.h>
+#if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
+ defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
+ #include <rtems/score/timespec.h>
+#endif
+
/*PAGE
*
* rtems_rate_monotonic_get_status
@@ -64,15 +69,51 @@ rtems_status_code rtems_rate_monotonic_get_status(
status->state = the_period->state;
if ( status->state == RATE_MONOTONIC_INACTIVE ) {
- status->ticks_since_last_period = 0;
- status->ticks_executed_since_last_period = 0;
+ #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
+ status->since_last_period.tv_sec = 0;
+ status->since_last_period.tv_nsec = 0;
+ #else
+ status->ticks_since_last_period = 0;
+ #endif
+ #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
+ status->executed_since_last_period.tv_sec = 0;
+ status->executed_since_last_period.tv_nsec = 0;
+ #else
+ status->ticks_executed_since_last_period = 0;
+ #endif
} else {
- status->ticks_since_last_period =
- _Watchdog_Ticks_since_boot - the_period->time_at_period;
+ /*
+ * Both nanoseconds granularity options have to know the uptime.
+ * This lets them share one single invocation of _TOD_Get_uptime().
+ */
+ #if defined(RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS) || \
+ defined(RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS)
+ struct timespec uptime;
+ _TOD_Get_uptime( &uptime );
+ #endif
+
+ #ifdef RTEMS_ENABLE_NANOSECOND_RATE_MONOTONIC_STATISTICS
+ _Timespec_Subtract(
+ &the_period->time_at_period,
+ &uptime,
+ &status->since_last_period
+ );
+ #else
+ status->ticks_since_last_period =
+ _Watchdog_Ticks_since_boot - the_period->time_at_period;
+ #endif
- status->ticks_executed_since_last_period =
- the_period->owner->ticks_executed -
- the_period->owner_ticks_executed_at_period;
+ #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS
+ _Timespec_Subtract(
+ &_Thread_Time_of_last_context_switch,
+ &uptime,
+ &status->executed_since_last_period
+ );
+ #else
+ status->ticks_executed_since_last_period =
+ the_period->owner->ticks_executed -
+ the_period->owner_ticks_executed_at_period;
+ #endif
}
_Thread_Enable_dispatch();