git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6045 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2013-07-30 09:19:07 +00:00
parent f569bcec23
commit 9cd24294b8
3 changed files with 56 additions and 6 deletions

View File

@ -80,6 +80,42 @@ typedef struct {
*/
#define _stats_increase_ctxswc() kernel_stats.n_ctxswc++
/**
* @brief Starts the measurement of a thread critical zone.
*/
#define _stats_start_measure_crit_thd() \
chTMStartMeasurementX(&kernel_stats.m_crit_thd)
/**
* @brief Stops the measurement of a thread critical zone.
*/
#define _stats_stop_measure_crit_thd() \
chTMStopMeasurementX(&kernel_stats.m_crit_thd)
/**
* @brief Starts the measurement of an ISR critical zone.
*/
#define _stats_start_measure_crit_isr() \
chTMStartMeasurementX(&kernel_stats.m_crit_isr)
/**
* @brief Stops the measurement of an ISR critical zone.
*/
#define _stats_stop_measure_crit_isr() \
chTMStopMeasurementX(&kernel_stats.m_crit_isr)
/**
* @brief Starts the measurement of an ISR duration.
*/
#define _stats_start_measure_isr() \
chTMStartMeasurementX(&kernel_stats.m_crit_isr)
/**
* @brief Stops the measurement of an ISR duration.
*/
#define _stats_stop_measure_isr() \
chTMStopMeasurementX(&kernel_stats.m_crit_isr)
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
@ -105,6 +141,12 @@ extern "C" {
/* Stub functions for when the statistics module is disabled. */
#define _stats_increase_irq()
#define _stats_increase_ctxswc()
#define _stats_start_measure_crit_thd()
#define _stats_stop_measure_crit_thd()
#define _stats_start_measure_crit_isr()
#define _stats_stop_measure_crit_isr()
#define _stats_start_measure_isr()
#define _stats_stop_measure_isr()
#endif /* !CH_DBG_STATISTICS */

View File

@ -61,8 +61,9 @@
*/
#define CH_IRQ_PROLOGUE() \
PORT_IRQ_PROLOGUE(); \
dbg_check_enter_isr(); \
_stats_increase_irq()
_stats_start_measure_isr(); \
_stats_increase_irq(); \
dbg_check_enter_isr()
/**
* @brief IRQ handler exit code.
@ -74,6 +75,7 @@
*/
#define CH_IRQ_EPILOGUE() \
dbg_check_leave_isr(); \
_stats_stop_measure_isr(); \
PORT_IRQ_EPILOGUE()
/**
@ -290,6 +292,7 @@ static inline void chSysEnable(void) {
static inline void chSysLock(void) {
port_lock();
_stats_start_measure_crit_thd();
dbg_check_lock();
}
@ -301,6 +304,7 @@ static inline void chSysLock(void) {
static inline void chSysUnlock(void) {
dbg_check_unlock();
_stats_stop_measure_crit_thd();
port_unlock();
}
@ -319,6 +323,7 @@ static inline void chSysUnlock(void) {
static inline void chSysLockFromISR(void) {
port_lock_from_isr();
_stats_start_measure_crit_isr();
dbg_check_lock_from_isr();
}
@ -338,6 +343,7 @@ static inline void chSysLockFromISR(void) {
static inline void chSysUnlockFromISR(void) {
dbg_check_unlock_from_isr();
_stats_stop_measure_crit_isr();
port_unlock_from_isr();
}

View File

@ -56,9 +56,11 @@ static rtcnt_t measurement_offset;
/* Module local functions. */
/*===========================================================================*/
static inline void tm_stop(time_measurement_t *tmp, rtcnt_t now) {
static inline void tm_stop(time_measurement_t *tmp,
rtcnt_t now,
rtcnt_t offset) {
tmp->last = now - tmp->last - measurement_offset;
tmp->last = now - tmp->last - offset;
tmp->cumulative += tmp->last;
if (tmp->last > tmp->worst)
tmp->worst = tmp->last;
@ -126,7 +128,7 @@ NOINLINE void chTMStartMeasurementX(time_measurement_t *tmp) {
*/
NOINLINE void chTMStopMeasurementX(time_measurement_t *tmp) {
tm_stop(tmp, chSysGetRealtimeCounterX());
tm_stop(tmp, chSysGetRealtimeCounterX(), measurement_offset);
}
#endif /* CH_CFG_USE_TM */
@ -150,7 +152,7 @@ NOINLINE void chTMChainMeasurementToX(time_measurement_t *tmp1,
tmp2->last = chSysGetRealtimeCounterX();
/* Stops previous measurement using the same time stamp.*/
tm_stop(tmp1, tmp2->last);
tm_stop(tmp1, tmp2->last, 0);
}
/** @} */