diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-07-31 12:26:02 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-07-31 12:26:02 +0000 |
commit | ceea042aaf3e373b598b3295c256feaef4e4236c (patch) | |
tree | 093a071d95eace2b0aec62bcf77f78d41df542fa | |
parent | 16044c7aeac671a4914749a387a6c526f0b2fdce (diff) | |
download | ChibiOS-ceea042aaf3e373b598b3295c256feaef4e4236c.tar.gz ChibiOS-ceea042aaf3e373b598b3295c256feaef4e4236c.tar.bz2 ChibiOS-ceea042aaf3e373b598b3295c256feaef4e4236c.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6056 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | os/kernel/include/chstats.h | 5 | ||||
-rw-r--r-- | os/kernel/include/chsys.h | 2 | ||||
-rw-r--r-- | os/kernel/include/chthreads.h | 3 | ||||
-rw-r--r-- | os/kernel/src/chstats.c | 5 | ||||
-rw-r--r-- | os/kernel/src/chthreads.c | 3 |
5 files changed, 12 insertions, 6 deletions
diff --git a/os/kernel/include/chstats.h b/os/kernel/include/chstats.h index d40117882..389fbf583 100644 --- a/os/kernel/include/chstats.h +++ b/os/kernel/include/chstats.h @@ -55,7 +55,6 @@ * @brief Type of a kernel statistics structure.
*/
typedef struct {
- time_measurement_t *current; /**< @brief Currently under measurement.*/
ucnt_t n_irq; /**< @brief Number of IRQs. */
ucnt_t n_ctxswc; /**< @brief Number of context switches. */
time_measurement_t m_crit_thd; /**< @brief Measurement of threads
@@ -81,7 +80,7 @@ extern "C" { #endif
void _stats_init(void);
void _stats_increase_irq(void);
- void _stats_increase_ctxswc(void);
+ void _stats_ctxswc(thread_t *ntp, thread_t *otp);
void _stats_start_measure_crit_thd(void);
void _stats_stop_measure_crit_thd(void);
void _stats_start_measure_crit_isr(void);
@@ -98,7 +97,7 @@ extern "C" { /* Stub functions for when the statistics module is disabled. */
#define _stats_increase_irq()
-#define _stats_increase_ctxswc()
+#define _stats_ctxswc(old, new)
#define _stats_start_measure_crit_thd()
#define _stats_stop_measure_crit_thd()
#define _stats_start_measure_crit_isr()
diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h index bfb521d65..9eaf5d8e6 100644 --- a/os/kernel/include/chsys.h +++ b/os/kernel/include/chsys.h @@ -207,7 +207,7 @@ #define chSysSwitch(ntp, otp) { \
\
dbg_trace(otp); \
- _stats_increase_ctxswc(); \
+ _stats_ctxswc(ntp, otp); \
CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp); \
port_switch(ntp, otp); \
}
diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index a945f8d7d..66d000d7e 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -250,6 +250,9 @@ typedef struct thread { */
void *p_mpool;
#endif
+#if CH_DBG_STATISTICS || defined(__DOXYGEN__)
+ time_measurement_t p_stats;
+#endif
#if defined(CH_CFG_THREAD_EXTRA_FIELDS)
/* Extra fields defined in chconf.h.*/
CH_CFG_THREAD_EXTRA_FIELDS
diff --git a/os/kernel/src/chstats.c b/os/kernel/src/chstats.c index 93739da17..06ac21d1d 100644 --- a/os/kernel/src/chstats.c +++ b/os/kernel/src/chstats.c @@ -83,11 +83,12 @@ void _stats_increase_irq(void) { }
/**
- * @brief Increases the context switch counter.
+ * @brief Updates context switch related statistics.
*/
-void _stats_increase_ctxswc(void) {
+void _stats_ctxswc(thread_t *ntp, thread_t *otp) {
kernel_stats.n_ctxswc++;
+ chTMChainMeasurementToX(&otp->p_stats, &ntp->p_stats);
}
/**
diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c index b707b4562..ff6e5e597 100644 --- a/os/kernel/src/chthreads.c +++ b/os/kernel/src/chthreads.c @@ -124,6 +124,9 @@ thread_t *_thread_init(thread_t *tp, tprio_t prio) { #if CH_DBG_ENABLE_STACK_CHECK
tp->p_stklimit = (stkalign_t *)(tp + 1);
#endif
+#if CH_DBG_STATISTICS || defined(__DOXYGEN__)
+ chTMStartMeasurementX(&tp->p_stats);
+#endif
#if defined(CH_CFG_THREAD_INIT_HOOK)
CH_CFG_THREAD_INIT_HOOK(tp);
#endif
|