From 1e51fa5f4de9f15a99e3cb1fd1787f1861304e7e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 29 Jul 2013 17:25:50 +0200 Subject: score: Add and use _Thread_Update_cpu_time_used() Fix _times(). --- cpukit/score/include/rtems/score/threadimpl.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'cpukit/score/include/rtems/score/threadimpl.h') 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 #include #include +#include #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. -- cgit v1.2.3