summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/timespecdivide.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/score/src/timespecdivide.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/score/src/timespecdivide.c')
-rw-r--r--cpukit/score/src/timespecdivide.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/cpukit/score/src/timespecdivide.c b/cpukit/score/src/timespecdivide.c
index 0535c22e11..74d6cdbc78 100644
--- a/cpukit/score/src/timespecdivide.c
+++ b/cpukit/score/src/timespecdivide.c
@@ -23,30 +23,35 @@
#include <rtems/score/tod.h>
void _Timespec_Divide(
- const struct timespec *time,
- uint32_t iterations,
- struct timespec *result
+ const struct timespec *lhs,
+ const struct timespec *rhs,
+ uint32_t *ival_percentage,
+ uint32_t *fval_percentage
)
{
- uint64_t t;
+ uint64_t left, right, answer;
/*
* 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;
+ left = lhs->tv_sec * (uint64_t)TOD_NANOSECONDS_PER_SECOND;
+ left += lhs->tv_nsec;
+ right = rhs->tv_sec * (uint64_t)TOD_NANOSECONDS_PER_SECOND;
+ right += rhs->tv_nsec;
- /*
- * Divide to get nanoseconds per iteration
- */
-
- t /= iterations;
+ if ( rhs == 0 ) {
+ *ival_percentage = 0;
+ *ival_percentage = 0;
+ return;
+ }
/*
* Put it back in the timespec result
*/
- result->tv_sec = t / TOD_NANOSECONDS_PER_SECOND;
- result->tv_nsec = t % TOD_NANOSECONDS_PER_SECOND;
+ answer = (left * 1000) / right;
+
+ *fval_percentage = answer % 1000;
+ *ival_percentage = answer / 1000;
}