summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-07-29 17:25:50 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-08-01 16:45:44 +0200
commit1e51fa5f4de9f15a99e3cb1fd1787f1861304e7e (patch)
tree2704821edf18abd2392e7e9ceeae4ad196487a20 /cpukit/score
parenttmtests/tm27: Fixes for RTEMS_DEBUG (diff)
downloadrtems-1e51fa5f4de9f15a99e3cb1fd1787f1861304e7e.tar.bz2
score: Add and use _Thread_Update_cpu_time_used()
Fix _times().
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/include/rtems/score/threadimpl.h19
-rw-r--r--cpukit/score/src/threaddispatch.c15
2 files changed, 23 insertions, 11 deletions
diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index f5a0ff9faa..e818bc8c50 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -23,6 +23,7 @@
#include <rtems/score/isr.h>
#include <rtems/score/objectimpl.h>
#include <rtems/score/statesimpl.h>
+#include <rtems/score/tod.h>
#ifdef __cplusplus
extern "C" {
@@ -651,6 +652,24 @@ RTEMS_INLINE_ROUTINE void _Thread_Signal_notification( Thread_Control *thread )
}
}
+RTEMS_INLINE_ROUTINE void _Thread_Update_cpu_time_used(
+ Thread_Control *executing,
+ Timestamp_Control *time_of_last_context_switch
+)
+{
+ Timestamp_Control uptime;
+ Timestamp_Control ran;
+
+ _TOD_Get_uptime( &uptime );
+ _Timestamp_Subtract(
+ time_of_last_context_switch,
+ &uptime,
+ &ran
+ );
+ *time_of_last_context_switch = uptime;
+ _Timestamp_Add_to( &executing->cpu_time_used, &ran );
+}
+
#if !defined(__DYNAMIC_REENT__)
/**
* This routine returns the C library re-enterant pointer.
diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c
index c5d0a2199b..09b5dbe105 100644
--- a/cpukit/score/src/threaddispatch.c
+++ b/cpukit/score/src/threaddispatch.c
@@ -105,17 +105,10 @@ void _Thread_Dispatch( void )
_ISR_Enable( level );
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
- {
- Timestamp_Control uptime, ran;
- _TOD_Get_uptime( &uptime );
- _Timestamp_Subtract(
- &_Thread_Time_of_last_context_switch,
- &uptime,
- &ran
- );
- _Timestamp_Add_to( &executing->cpu_time_used, &ran );
- _Thread_Time_of_last_context_switch = uptime;
- }
+ _Thread_Update_cpu_time_used(
+ executing,
+ &_Thread_Time_of_last_context_switch
+ );
#else
{
_TOD_Get_uptime( &_Thread_Time_of_last_context_switch );