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/score/src/threaddispatch.c | |
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/score/src/threaddispatch.c')
-rw-r--r-- | cpukit/score/src/threaddispatch.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c index 136433be17..4c903b6c2a 100644 --- a/cpukit/score/src/threaddispatch.c +++ b/cpukit/score/src/threaddispatch.c @@ -2,7 +2,7 @@ * Thread Handler * * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -30,6 +30,11 @@ #include <rtems/score/userext.h> #include <rtems/score/wkspace.h> +#ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS + + #include <rtems/score/timespec.h> +#endif + /*PAGE * * _Thread_Dispatch @@ -78,7 +83,17 @@ void _Thread_Dispatch( void ) heir->cpu_time_budget = _Thread_Ticks_per_timeslice; _ISR_Enable( level ); - heir->ticks_executed++; + #ifdef RTEMS_ENABLE_NANOSECOND_CPU_USAGE_STATISTICS + { + struct timespec uptime, ran; + _TOD_Get_uptime( &uptime ); + _Timespec_Subtract(&_Thread_Time_of_last_context_switch, &uptime, &ran); + _Timespec_Add_to( &executing->cpu_time_used, &ran ); + _Thread_Time_of_last_context_switch = uptime; + } + #else + heir->ticks_executed++; + #endif /* * Switch libc's task specific data. |