diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-05-17 22:46:45 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-05-17 22:46:45 +0000 |
commit | c3330a88ee5d674b09dded32ef1ccba26a9c3034 (patch) | |
tree | f7f247449fc18bc299ef695c3503f9b7790db97a /cpukit/libcsupport | |
parent | Add .rh clause to extra_arg. (diff) | |
download | rtems-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/libcsupport')
-rw-r--r-- | cpukit/libcsupport/src/__times.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/cpukit/libcsupport/src/__times.c b/cpukit/libcsupport/src/__times.c index 733befe8c9..669ed5ca25 100644 --- a/cpukit/libcsupport/src/__times.c +++ b/cpukit/libcsupport/src/__times.c @@ -22,6 +22,9 @@ #include <sys/time.h> #include <errno.h> #include <assert.h> +#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS + #include <rtems/score/timespec.h> +#endif clock_t _times( struct tms *ptms @@ -48,7 +51,28 @@ clock_t _times( * this thread. */ - ptms->tms_utime = _Thread_Executing->ticks_executed; + #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS + { + struct timespec per_tick; + uint32_t ticks; + uint32_t fractional_ticks; + + per_tick.tv_sec = + _TOD_Microseconds_per_tick / TOD_MILLISECONDS_PER_SECOND; + per_tick.tv_nsec = + (_TOD_Microseconds_per_tick % TOD_MILLISECONDS_PER_SECOND) / 1000; + + _Timespec_Divide( + &_Thread_Executing->cpu_time_used, + &per_tick, + &ticks, + &fractional_ticks + ); + ptms->tms_utime = ticks; + } + #else + ptms->tms_utime = _Thread_Executing->ticks_executed; + #endif ptms->tms_stime = ticks; ptms->tms_cutime = 0; ptms->tms_cstime = 0; |