summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/__times.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libcsupport/src/__times.c')
-rw-r--r--cpukit/libcsupport/src/__times.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/cpukit/libcsupport/src/__times.c b/cpukit/libcsupport/src/__times.c
index ea6d1c65a7..a30f720f20 100644
--- a/cpukit/libcsupport/src/__times.c
+++ b/cpukit/libcsupport/src/__times.c
@@ -26,9 +26,11 @@
#include <rtems.h>
#include <sys/times.h>
-#include <time.h>
#include <sys/time.h>
-#include <errno.h>
+
+#include <string.h>
+#include <time.h>
+
#include <rtems/seterr.h>
#include <rtems/score/todimpl.h>
#include <rtems/score/timestamp.h>
@@ -42,11 +44,12 @@ clock_t _times(
)
{
rtems_interval ticks, us_per_tick;
- Thread_Control *executing;
if ( !ptms )
rtems_set_errno_and_return_minus_one( EFAULT );
+ memset( ptms, 0, sizeof( *ptms ) );
+
/*
* This call does not depend on TOD being initialized and can't fail.
*/
@@ -62,11 +65,12 @@ clock_t _times(
* this thread.
*/
{
+ Timestamp_Control cpu_time_used;
Timestamp_Control per_tick;
uint32_t ticks_of_executing;
uint32_t fractional_ticks;
- Per_CPU_Control *cpu_self;
+ _Thread_Get_CPU_time_used( _Thread_Get_executing(), &cpu_time_used );
_Timestamp_Set(
&per_tick,
rtems_configuration_get_microseconds_per_tick() /
@@ -74,25 +78,17 @@ clock_t _times(
(rtems_configuration_get_nanoseconds_per_tick() %
TOD_NANOSECONDS_PER_SECOND)
);
-
- cpu_self = _Thread_Dispatch_disable();
- executing = _Thread_Executing;
- _Thread_Update_cpu_time_used(
- executing,
- &_Thread_Time_of_last_context_switch
- );
_Timestamp_Divide(
- &executing->cpu_time_used,
+ &cpu_time_used,
&per_tick,
&ticks_of_executing,
&fractional_ticks
);
- _Thread_Dispatch_enable( cpu_self );
+
ptms->tms_utime = ticks_of_executing * us_per_tick;
}
+
ptms->tms_stime = ticks * us_per_tick;
- ptms->tms_cutime = 0;
- ptms->tms_cstime = 0;
return ticks * us_per_tick;
}