Index: cpukit/libcsupport/src/__times.c
===================================================================
--- cpukit/libcsupport/src/__times.c	(revision 1547b623ebfbce434ff13e83e3d3e23d1de9fb7e)
+++ cpukit/libcsupport/src/__times.c	(revision d37adfe5dd82cc3c933eb521b8f800c342af0e52)
@@ -27,7 +27,9 @@
 
 #include <sys/times.h>
+#include <sys/time.h>
+
+#include <string.h>
 #include <time.h>
-#include <sys/time.h>
-#include <errno.h>
+
 #include <rtems/seterr.h>
 #include <rtems/score/todimpl.h>
@@ -43,8 +45,9 @@
 {
   rtems_interval ticks, us_per_tick;
-  Thread_Control *executing;
 
   if ( !ptms )
     rtems_set_errno_and_return_minus_one( EFAULT );
+
+  memset( ptms, 0, sizeof( *ptms ) );
 
   /*
@@ -63,9 +66,10 @@
    */
   {
+    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,
@@ -75,23 +79,15 @@
 	  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;
Index: cpukit/libmisc/cpuuse/cpuusagereport.c
===================================================================
--- cpukit/libmisc/cpuuse/cpuusagereport.c	(revision 1547b623ebfbce434ff13e83e3d3e23d1de9fb7e)
+++ cpukit/libmisc/cpuuse/cpuusagereport.c	(revision d37adfe5dd82cc3c933eb521b8f800c342af0e52)
@@ -45,5 +45,5 @@
   char                 name[13];
   uint32_t             ival, fval;
-  Timestamp_Control  uptime, total, ran, uptime_at_last_reset;
+  Timestamp_Control  uptime, total, used, uptime_at_last_reset;
   uint32_t seconds, nanoseconds;
 
@@ -91,36 +91,21 @@
         );
 
-        {
-          Timestamp_Control last;
+        _Thread_Get_CPU_time_used( the_thread, &used );
+        _TOD_Get_uptime( &uptime );
+        _Timestamp_Subtract( &uptime_at_last_reset, &uptime, &total );
+        _Timestamp_Divide( &used, &total, &ival, &fval );
 
-          /*
-           * If this is the currently executing thread, account for time
-           * since the last context switch.
-           */
-          ran = the_thread->cpu_time_used;
-          if ( _Thread_Get_time_of_last_context_switch( the_thread, &last ) ) {
-            Timestamp_Control used;
-            _TOD_Get_uptime( &uptime );
-            _Timestamp_Subtract( &last, &uptime, &used );
-            _Timestamp_Add_to( &ran, &used );
-          } else {
-            _TOD_Get_uptime( &uptime );
-          }
-          _Timestamp_Subtract( &uptime_at_last_reset, &uptime, &total );
-          _Timestamp_Divide( &ran, &total, &ival, &fval );
+        /*
+         * Print the information
+         */
 
-          /*
-           * Print the information
-           */
-
-          seconds = _Timestamp_Get_seconds( &ran );
-          nanoseconds = _Timestamp_Get_nanoseconds( &ran ) /
-            TOD_NANOSECONDS_PER_MICROSECOND;
-          (*print)( context,
-            "%7" PRIu32 ".%06" PRIu32 " |%4" PRIu32 ".%03" PRIu32 "\n",
-            seconds, nanoseconds,
-            ival, fval
-          );
-        }
+        seconds = _Timestamp_Get_seconds( &used );
+        nanoseconds = _Timestamp_Get_nanoseconds( &used ) /
+          TOD_NANOSECONDS_PER_MICROSECOND;
+        (*print)( context,
+          "%7" PRIu32 ".%06" PRIu32 " |%4" PRIu32 ".%03" PRIu32 "\n",
+          seconds, nanoseconds,
+          ival, fval
+        );
       }
     }
Index: cpukit/libmisc/cpuuse/cpuusagereset.c
===================================================================
--- cpukit/libmisc/cpuuse/cpuusagereset.c	(revision 1547b623ebfbce434ff13e83e3d3e23d1de9fb7e)
+++ cpukit/libmisc/cpuuse/cpuusagereset.c	(revision d37adfe5dd82cc3c933eb521b8f800c342af0e52)
@@ -22,4 +22,5 @@
 #include <rtems/score/percpu.h>
 #include <rtems/score/todimpl.h>
+#include <rtems/score/schedulerimpl.h>
 #include <rtems/score/watchdogimpl.h>
 
@@ -28,5 +29,9 @@
 )
 {
+  ISR_lock_Context lock_context;
+
+  _Scheduler_Acquire( the_thread, &lock_context );
   _Timestamp_Set_to_zero( &the_thread->cpu_time_used );
+  _Scheduler_Release( the_thread, &lock_context );
 }
 
@@ -45,5 +50,5 @@
     Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
 
-    cpu->time_of_last_context_switch = CPU_usage_Uptime_at_last_reset;
+    cpu->cpu_usage_timestamp = CPU_usage_Uptime_at_last_reset;
   }
 
Index: cpukit/libmisc/cpuuse/cpuusagetop.c
===================================================================
--- cpukit/libmisc/cpuuse/cpuusagetop.c	(revision 1547b623ebfbce434ff13e83e3d3e23d1de9fb7e)
+++ cpukit/libmisc/cpuuse/cpuusagetop.c	(revision d37adfe5dd82cc3c933eb521b8f800c342af0e52)
@@ -219,9 +219,11 @@
 {
   rtems_cpu_usage_data* data = (rtems_cpu_usage_data*) arg;
-  Timestamp_Control     usage = thread->cpu_time_used;
+  Timestamp_Control     usage;
   Timestamp_Control     current = data->zero;
   int                   j;
 
   data->stack_size += thread->Start.Initial_stack.size;
+
+  _Thread_Get_CPU_time_used(thread, &usage);
 
   for (j = 0; j < data->last_task_count; j++)
@@ -498,23 +500,4 @@
 
       /*
-       * If this is the currently executing thread, account for time since
-       * the last context switch.
-       */
-      if (_Thread_Get_time_of_last_context_switch(thread, &last))
-      {
-        Timestamp_Control used;
-        Timestamp_Control now;
-
-        /*
-         * Get the current uptime and assume we are not pre-empted to
-         * measure the time from the last switch this thread and now.
-         */
-        _TOD_Get_uptime(&now);
-        _Timestamp_Subtract(&last, &now, &used);
-        _Timestamp_Add_to(&usage, &used);
-        _Timestamp_Add_to(&current_usage, &used);
-      }
-
-      /*
        * Print the information
        */
Index: cpukit/rtems/src/ratemonperiod.c
===================================================================
--- cpukit/rtems/src/ratemonperiod.c	(revision 1547b623ebfbce434ff13e83e3d3e23d1de9fb7e)
+++ cpukit/rtems/src/ratemonperiod.c	(revision d37adfe5dd82cc3c933eb521b8f800c342af0e52)
@@ -46,32 +46,19 @@
    *  Determine cpu usage since period initiated.
    */
-  used = owning_thread->cpu_time_used;
-
-  if (owning_thread == _Thread_Executing) {
-
-    Timestamp_Control ran;
-
-    /* How much time time since last context switch */
-    _Timestamp_Subtract(
-      &_Thread_Time_of_last_context_switch, &uptime, &ran
-    );
-
-    /* cpu usage += ran */
-    _Timestamp_Add_to( &used, &ran );
-
-    /*
-     *  The cpu usage info was reset while executing.  Can't
-     *  determine a status.
-     */
-    if (_Timestamp_Less_than(&used, &the_period->cpu_usage_period_initiated))
-      return false;
-
-     /* used = current cpu usage - cpu usage at start of period */
-    _Timestamp_Subtract(
-       &the_period->cpu_usage_period_initiated,
-       &used,
-       cpu_since_last_period
-    );
-  }
+  _Thread_Get_CPU_time_used( owning_thread, &used );
+
+  /*
+   *  The cpu usage info was reset while executing.  Can't
+   *  determine a status.
+   */
+  if ( _Timestamp_Less_than( &used, &the_period->cpu_usage_period_initiated ) )
+    return false;
+
+   /* used = current cpu usage - cpu usage at start of period */
+  _Timestamp_Subtract(
+    &the_period->cpu_usage_period_initiated,
+    &used,
+    cpu_since_last_period
+  );
 
   return true;
@@ -80,38 +67,16 @@
 void _Rate_monotonic_Restart( Rate_monotonic_Control *the_period )
 {
-  Thread_Control    *owning_thread = the_period->owner;
-  Timestamp_Control  uptime;
-  ISR_Level          level;
-
-  _TOD_Get_uptime( &uptime );
+  ISR_Level level;
 
   /*
    *  Set the starting point and the CPU time used for the statistics.
    */
-  the_period->time_period_initiated = uptime;
-  the_period->cpu_usage_period_initiated = owning_thread->cpu_time_used;
-
-  /*
-   *  We need to take into account how much time the
-   *  executing thread has run since the last context switch.  When this
-   *  routine is invoked from rtems_rate_monotonic_period, the owner will
-   *  be the executing thread.  When this routine is invoked from
-   *  _Rate_monotonic_Timeout, it will not.
-   */
-  if (owning_thread == _Thread_Executing) {
-    Timestamp_Control ran;
-
-    /*
-     *  Adjust the CPU time used to account for the time since last
-     *  context switch.
-     */
-    _Timestamp_Subtract(
-      &_Thread_Time_of_last_context_switch, &uptime, &ran
-    );
-
-    _Timestamp_Add_to( &the_period->cpu_usage_period_initiated, &ran );
-  }
-
-  _Scheduler_Release_job( owning_thread, the_period->next_length );
+  _TOD_Get_uptime( &the_period->time_period_initiated );
+  _Thread_Get_CPU_time_used(
+    the_period->owner,
+    &the_period->cpu_usage_period_initiated
+  );
+
+  _Scheduler_Release_job( the_period->owner, the_period->next_length );
 
   _ISR_Disable( level );
Index: cpukit/score/Makefile.am
===================================================================
--- cpukit/score/Makefile.am	(revision 1547b623ebfbce434ff13e83e3d3e23d1de9fb7e)
+++ cpukit/score/Makefile.am	(revision d37adfe5dd82cc3c933eb521b8f800c342af0e52)
@@ -306,4 +306,5 @@
 libscore_a_SOURCES += src/threadentryadaptornumeric.c
 libscore_a_SOURCES += src/threadentryadaptorpointer.c
+libscore_a_SOURCES += src/threadgetcputimeused.c
 libscore_a_SOURCES += src/threadglobalconstruction.c
 libscore_a_SOURCES += src/threadtimeout.c
Index: cpukit/score/include/rtems/score/percpu.h
===================================================================
--- cpukit/score/include/rtems/score/percpu.h	(revision 1547b623ebfbce434ff13e83e3d3e23d1de9fb7e)
+++ cpukit/score/include/rtems/score/percpu.h	(revision d37adfe5dd82cc3c933eb521b8f800c342af0e52)
@@ -334,6 +334,15 @@
   volatile bool dispatch_necessary;
 
-  /** This is the time of the last context switch on this CPU. */
-  Timestamp_Control time_of_last_context_switch;
+  /**
+   * @brief The CPU usage timestamp contains the time point of the last heir
+   * thread change or last CPU usage update of the executing thread of this
+   * processor.
+   *
+   * Protected by the scheduler lock.
+   *
+   * @see _Scheduler_Update_heir(), _Thread_Dispatch_update_heir() and
+   * _Thread_Get_CPU_time_used().
+   */
+  Timestamp_Control cpu_usage_timestamp;
 
   /**
@@ -682,6 +691,4 @@
 #define _Thread_Dispatch_necessary \
   _Per_CPU_Get()->dispatch_necessary
-#define _Thread_Time_of_last_context_switch \
-  _Per_CPU_Get()->time_of_last_context_switch
 
 /**
Index: cpukit/score/include/rtems/score/schedulerimpl.h
===================================================================
--- cpukit/score/include/rtems/score/schedulerimpl.h	(revision 1547b623ebfbce434ff13e83e3d3e23d1de9fb7e)
+++ cpukit/score/include/rtems/score/schedulerimpl.h	(revision d37adfe5dd82cc3c933eb521b8f800c342af0e52)
@@ -627,17 +627,4 @@
 
 #endif /* defined(__RTEMS_HAVE_SYS_CPUSET_H__) */
-
-RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir(
-  Thread_Control *new_heir,
-  bool            force_dispatch
-)
-{
-  Thread_Control *heir = _Thread_Heir;
-
-  if ( heir != new_heir && ( heir->is_preemptible || force_dispatch ) ) {
-    _Thread_Heir = new_heir;
-    _Thread_Dispatch_necessary = true;
-  }
-}
 
 RTEMS_INLINE_ROUTINE void _Scheduler_Generic_block(
@@ -1357,4 +1344,23 @@
 ISR_LOCK_DECLARE( extern, _Scheduler_Lock )
 
+RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir(
+  Thread_Control *new_heir,
+  bool            force_dispatch
+)
+{
+  Thread_Control *heir = _Thread_Heir;
+
+  if ( heir != new_heir && ( heir->is_preemptible || force_dispatch ) ) {
+#if defined(RTEMS_SMP)
+    /* We need this state only for _Thread_Get_CPU_time_used() */
+    _Scheduler_Thread_change_state( heir, THREAD_SCHEDULER_BLOCKED );
+    _Scheduler_Thread_change_state( new_heir, THREAD_SCHEDULER_SCHEDULED );
+#endif
+    _Thread_Update_CPU_time_used( heir, _Thread_Get_CPU( heir ) );
+    _Thread_Heir = new_heir;
+    _Thread_Dispatch_necessary = true;
+  }
+}
+
 /**
  * @brief Acquires the scheduler instance of the thread.
Index: cpukit/score/include/rtems/score/threadimpl.h
===================================================================
--- cpukit/score/include/rtems/score/threadimpl.h	(revision 1547b623ebfbce434ff13e83e3d3e23d1de9fb7e)
+++ cpukit/score/include/rtems/score/threadimpl.h	(revision d37adfe5dd82cc3c933eb521b8f800c342af0e52)
@@ -579,34 +579,4 @@
 
 /**
- * @brief Returns @a true and sets time_of_context_switch to the
- * time of the last context switch when the thread is currently executing
- * in the system, otherwise @a false.
- */
-RTEMS_INLINE_ROUTINE bool _Thread_Get_time_of_last_context_switch(
-  Thread_Control    *the_thread,
-  Timestamp_Control *time_of_context_switch
-)
-{
-  bool retval = false;
-
-  _Thread_Disable_dispatch();
-  #ifndef RTEMS_SMP
-    if ( _Thread_Executing->Object.id == the_thread->Object.id ) {
-      *time_of_context_switch = _Thread_Time_of_last_context_switch;
-      retval = true;
-    }
-  #else
-    if ( _Thread_Is_executing_on_a_processor( the_thread ) ) {
-      *time_of_context_switch =
-        _Thread_Get_CPU( the_thread )->time_of_last_context_switch;
-      retval = true;
-    }
-  #endif
-  _Thread_Enable_dispatch();
-  return retval;
-}
-
-
-/**
  * This function returns true if the_thread is the heir
  * thread, and false otherwise.
@@ -804,4 +774,18 @@
 }
 
+RTEMS_INLINE_ROUTINE void _Thread_Update_CPU_time_used(
+  Thread_Control  *the_thread,
+  Per_CPU_Control *cpu
+)
+{
+  Timestamp_Control last;
+  Timestamp_Control ran;
+
+  last = cpu->cpu_usage_timestamp;
+  _TOD_Get_uptime( &cpu->cpu_usage_timestamp );
+  _Timestamp_Subtract( &last, &cpu->cpu_usage_timestamp, &ran );
+  _Timestamp_Add_to( &the_thread->cpu_time_used, &ran );
+}
+
 #if defined( RTEMS_SMP )
 RTEMS_INLINE_ROUTINE void _Thread_Dispatch_update_heir(
@@ -811,4 +795,6 @@
 )
 {
+  _Thread_Update_CPU_time_used( cpu_for_heir->heir, cpu_for_heir );
+
   cpu_for_heir->heir = heir;
 
@@ -821,21 +807,8 @@
 #endif
 
-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 );
-}
+void _Thread_Get_CPU_time_used(
+  Thread_Control    *the_thread,
+  Timestamp_Control *cpu_time_used
+);
 
 RTEMS_INLINE_ROUTINE void _Thread_Action_control_initialize(
Index: cpukit/score/src/schedulersmpstartidle.c
===================================================================
--- cpukit/score/src/schedulersmpstartidle.c	(revision 1547b623ebfbce434ff13e83e3d3e23d1de9fb7e)
+++ cpukit/score/src/schedulersmpstartidle.c	(revision d37adfe5dd82cc3c933eb521b8f800c342af0e52)
@@ -23,4 +23,5 @@
   Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_node( thread );
 
+  _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED );
   node->state = SCHEDULER_SMP_NODE_SCHEDULED;
 
Index: cpukit/score/src/threaddispatch.c
===================================================================
--- cpukit/score/src/threaddispatch.c	(revision 1547b623ebfbce434ff13e83e3d3e23d1de9fb7e)
+++ cpukit/score/src/threaddispatch.c	(revision d37adfe5dd82cc3c933eb521b8f800c342af0e52)
@@ -109,9 +109,4 @@
 #endif
 
-    _Thread_Update_cpu_time_used(
-      executing,
-      &cpu_self->time_of_last_context_switch
-    );
-
     _User_extensions_Thread_switch( executing, heir );
     _Thread_Save_fp( executing );
Index: cpukit/score/src/threadgetcputimeused.c
===================================================================
--- cpukit/score/src/threadgetcputimeused.c	(revision d37adfe5dd82cc3c933eb521b8f800c342af0e52)
+++ cpukit/score/src/threadgetcputimeused.c	(revision d37adfe5dd82cc3c933eb521b8f800c342af0e52)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/score/threadimpl.h>
+#include <rtems/score/schedulerimpl.h>
+
+static bool _Thread_Is_scheduled( const Thread_Control *the_thread )
+{
+#if defined(RTEMS_SMP)
+  return the_thread->Scheduler.state == THREAD_SCHEDULER_SCHEDULED;
+#else
+  return _Thread_Is_executing( the_thread );
+#endif
+}
+
+void _Thread_Get_CPU_time_used(
+  Thread_Control    *the_thread,
+  Timestamp_Control *cpu_time_used
+)
+{
+  ISR_lock_Context lock_context;
+
+  _Scheduler_Acquire( the_thread, &lock_context );
+
+  if ( _Thread_Is_scheduled( the_thread ) ) {
+    _Thread_Update_CPU_time_used( the_thread, _Thread_Get_CPU( the_thread ) );
+  }
+
+  *cpu_time_used = the_thread->cpu_time_used;
+
+  _Scheduler_Release( the_thread, &lock_context );
+}
