summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/percpu.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-03-03 07:02:03 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-03-17 08:27:47 +0100
commitd37adfe5dd82cc3c933eb521b8f800c342af0e52 (patch)
tree5f4a77976b9ae35594d00b0bb58e18bb62a9b541 /cpukit/score/include/rtems/score/percpu.h
parentbsp/realview_pbx_a9_qemu: Fix compiler flags (diff)
downloadrtems-d37adfe5dd82cc3c933eb521b8f800c342af0e52.tar.bz2
score: Fix CPU time used by executing threads
The CPU time used of a thread was previously maintained per-processor mostly during _Thread_Dispatch(). However, on SMP configurations the actual processor of a thread is difficult to figure out since thread dispatching is a highly asynchronous process (e.g. via inter-processor interrupts). Only the intended processor of a thread is known to the scheduler easily. Do the CPU usage accounting during thread heir updates in the context of the scheduler operations. Provide the function _Thread_Get_CPU_time_used() to get the CPU usage of a thread using proper locks to get a consistent value. Close #2627.
Diffstat (limited to 'cpukit/score/include/rtems/score/percpu.h')
-rw-r--r--cpukit/score/include/rtems/score/percpu.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/cpukit/score/include/rtems/score/percpu.h b/cpukit/score/include/rtems/score/percpu.h
index 22017889b3..95c93ddf3a 100644
--- a/cpukit/score/include/rtems/score/percpu.h
+++ b/cpukit/score/include/rtems/score/percpu.h
@@ -333,8 +333,17 @@ typedef struct Per_CPU_Control {
*/
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;
/**
* @brief Watchdog state for this processor.
@@ -681,8 +690,6 @@ bool _Per_CPU_State_wait_for_non_initial_state(
_Per_CPU_Get()->interrupt_stack_high
#define _Thread_Dispatch_necessary \
_Per_CPU_Get()->dispatch_necessary
-#define _Thread_Time_of_last_context_switch \
- _Per_CPU_Get()->time_of_last_context_switch
/**
* @brief Returns the thread control block of the executing thread.