diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-07-29 17:25:50 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-08-01 16:45:44 +0200 |
commit | 1e51fa5f4de9f15a99e3cb1fd1787f1861304e7e (patch) | |
tree | 2704821edf18abd2392e7e9ceeae4ad196487a20 /cpukit/libcsupport/src/__times.c | |
parent | tmtests/tm27: Fixes for RTEMS_DEBUG (diff) | |
download | rtems-1e51fa5f4de9f15a99e3cb1fd1787f1861304e7e.tar.bz2 |
score: Add and use _Thread_Update_cpu_time_used()
Fix _times().
Diffstat (limited to 'cpukit/libcsupport/src/__times.c')
-rw-r--r-- | cpukit/libcsupport/src/__times.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/cpukit/libcsupport/src/__times.c b/cpukit/libcsupport/src/__times.c index f143bb8209..4596453d56 100644 --- a/cpukit/libcsupport/src/__times.c +++ b/cpukit/libcsupport/src/__times.c @@ -29,6 +29,7 @@ #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ #include <rtems/score/timestamp.h> #endif +#include <rtems/score/threadimpl.h> /** * POSIX 1003.1b 4.5.2 - Get Process Times @@ -38,6 +39,7 @@ clock_t _times( ) { rtems_interval ticks; + Thread_Control *executing; if ( !ptms ) rtems_set_errno_and_return_minus_one( EFAULT ); @@ -59,7 +61,7 @@ clock_t _times( #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ { Timestamp_Control per_tick; - uint32_t ticks; + uint32_t ticks_of_executing; uint32_t fractional_ticks; _Timestamp_Set( @@ -70,16 +72,24 @@ clock_t _times( TOD_NANOSECONDS_PER_SECOND) ); + _Thread_Disable_dispatch(); + executing = _Thread_Executing; + _Thread_Update_cpu_time_used( + executing, + &_Thread_Time_of_last_context_switch + ); _Timestamp_Divide( - &_Thread_Get_executing()->cpu_time_used, + &executing->cpu_time_used, &per_tick, - &ticks, + &ticks_of_executing, &fractional_ticks ); - ptms->tms_utime = ticks; + _Thread_Enable_dispatch(); + ptms->tms_utime = ticks_of_executing / 100; } #else - ptms->tms_utime = _Thread_Get_executing()->cpu_time_used; + executing = _Thread_Get_executing(); + ptms->tms_utime = executing->cpu_time_used; #endif ptms->tms_stime = ticks; ptms->tms_cutime = 0; |