From c3330a88ee5d674b09dded32ef1ccba26a9c3034 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 17 May 2007 22:46:45 +0000 Subject: 2007-05-17 Joel Sherrill * 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. --- cpukit/score/src/timespecdividebyinteger.c | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 cpukit/score/src/timespecdividebyinteger.c (limited to 'cpukit/score/src/timespecdividebyinteger.c') diff --git a/cpukit/score/src/timespecdividebyinteger.c b/cpukit/score/src/timespecdividebyinteger.c new file mode 100644 index 0000000000..eecd7c4e30 --- /dev/null +++ b/cpukit/score/src/timespecdividebyinteger.c @@ -0,0 +1,52 @@ +/** + * @file score/src/timespecdividebyinteger.c + */ + +/* + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +void _Timespec_Divide_by_integer( + const struct timespec *time, + uint32_t iterations, + struct timespec *result +) +{ + uint64_t t; + + /* + * For math simplicity just convert the timespec to nanoseconds + * in a 64-bit integer. + */ + t = time->tv_sec * TOD_NANOSECONDS_PER_SECOND; + t += time->tv_nsec; + + /* + * Divide to get nanoseconds per iteration + */ + + t /= iterations; + + /* + * Put it back in the timespec result + */ + + result->tv_sec = t / TOD_NANOSECONDS_PER_SECOND; + result->tv_nsec = t % TOD_NANOSECONDS_PER_SECOND; +} -- cgit v1.2.3