Minor improvements to VTs and VT-storm test application.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14531 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-06-12 05:45:59 +00:00
parent 31941eb642
commit f093064acb
6 changed files with 30 additions and 22 deletions

View File

@ -539,7 +539,7 @@ static inline void ch_dlist_insert(ch_delta_list_t *dlhp,
/* The delta list is scanned in order to find the correct position for /* The delta list is scanned in order to find the correct position for
this element. */ this element. */
dlp = dlhp->next; dlp = dlhp->next;
while (dlp->delta < delta) { while (likely(dlp->delta < delta)) {
/* Debug assert if the element is already in the list.*/ /* Debug assert if the element is already in the list.*/
chDbgAssert(dlp != dlep, "element already in list"); chDbgAssert(dlp != dlep, "element already in list");

View File

@ -479,20 +479,21 @@ void chVTDoTickI(void) {
if (ch_dlist_isempty(&vtlp->dlist)) { if (ch_dlist_isempty(&vtlp->dlist)) {
vt_insert_first(vtlp, vtp, now, delay); vt_insert_first(vtlp, vtp, now, delay);
}
else {
/* Delay as delta from 'lasttime'. Note, it can overflow and the value
becomes lower than 'nowdelta'. In that case the delta is shortened
to make it fit the numeric range and the timer will be triggered
"nowdelta" cycles earlier.*/
delta = nowdelta + delay;
if (delta < nowdelta) {
delta = delay;
}
/* Insert into delta list. */ return;
ch_dlist_insert(&vtlp->dlist, &vtp->dlist, delta);
} }
/* Delay as delta from 'lasttime'. Note, it can overflow and the value
becomes lower than 'nowdelta'. In that case the delta is shortened
to make it fit the numeric range and the timer will be triggered
"nowdelta" cycles earlier.*/
delta = nowdelta + delay;
if (delta < nowdelta) {
delta = delay;
}
/* Insert into delta list. */
ch_dlist_insert(&vtlp->dlist, &vtp->dlist, delta);
} }
} }

View File

@ -587,7 +587,7 @@
* @note The default is @p FALSE. * @note The default is @p FALSE.
*/ */
#if !defined(CH_DBG_ENABLE_ASSERTS) #if !defined(CH_DBG_ENABLE_ASSERTS)
#define CH_DBG_ENABLE_ASSERTS TRUE #define CH_DBG_ENABLE_ASSERTS FALSE
#endif #endif
/** /**

View File

@ -5,7 +5,7 @@
# Compiler options here. # Compiler options here.
ifeq ($(USE_OPT),) ifeq ($(USE_OPT),)
USE_OPT = -Og -ggdb -fomit-frame-pointer -falign-functions=16 USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
endif endif
# C specific options here (added to USE_OPT). # C specific options here (added to USE_OPT).

View File

@ -283,9 +283,11 @@ void vt_storm_execute(const vt_storm_config_t *cfg) {
/* Starting continuous timer.*/ /* Starting continuous timer.*/
vtcus = 0; vtcus = 0;
delay = TIME_US2I(120); delay = TIME_US2I(128);
saturated = false; saturated = false;
do { do {
sysinterval_t decrease;
/* Starting sweepers.*/ /* Starting sweepers.*/
chSysLock(); chSysLock();
chVTSetI(&watchdog, TIME_MS2I(501), watchdog_cb, NULL); chVTSetI(&watchdog, TIME_MS2I(501), watchdog_cb, NULL);
@ -302,7 +304,7 @@ void vt_storm_execute(const vt_storm_config_t *cfg) {
chVTSetI(&guard3, TIME_MS2I(250) + (CH_CFG_TIME_QUANTUM * 2), guard_cb, NULL); chVTSetI(&guard3, TIME_MS2I(250) + (CH_CFG_TIME_QUANTUM * 2), guard_cb, NULL);
/* Letting them run for half second.*/ /* Letting them run for half second.*/
chThdSleepS(TIME_MS2I(500)); chThdSleepS(TIME_MS2I(100));
/* Stopping everything.*/ /* Stopping everything.*/
chVTResetI(&watchdog); chVTResetI(&watchdog);
@ -326,13 +328,18 @@ void vt_storm_execute(const vt_storm_config_t *cfg) {
palToggleLine(config->line); palToggleLine(config->line);
chprintf(cfg->out, "."); chprintf(cfg->out, ".");
if (delay >= TIME_US2I(1)) { // if (delay >= TIME_US2I(1)) {
delay -= TIME_US2I(1); // delay -= TIME_US2I(1);
// }
decrease = delay / (sysinterval_t)64;
if (decrease == (sysinterval_t)0) {
decrease = (sysinterval_t)1;
} }
delay = delay - decrease;
} while (delay >= (sysinterval_t)VT_STORM_CFG_MIN_DELAY); } while (delay >= (sysinterval_t)VT_STORM_CFG_MIN_DELAY);
if (saturated) { if (saturated) {
chprintf(cfg->out, "\r\nSaturated at %u uS", TIME_I2US(delay)); chprintf(cfg->out, "\r\nSaturated at %u uS %u ticks", TIME_I2US(delay), delay);
chprintf(cfg->out, "\r\nContinuous ticks %u\r\n\r\n", vtcus); chprintf(cfg->out, "\r\nContinuous ticks %u\r\n\r\n", vtcus);
} }
else { else {

View File

@ -41,7 +41,7 @@
* @brief Timings randomization. * @brief Timings randomization.
*/ */
#if !defined(VT_STORM_CFG_RANDOMIZE) || defined(__DOXYGEN__) #if !defined(VT_STORM_CFG_RANDOMIZE) || defined(__DOXYGEN__)
#define VT_STORM_CFG_RANDOMIZE TRUE #define VT_STORM_CFG_RANDOMIZE FALSE
#endif #endif
/** /**
@ -62,7 +62,7 @@
* @brief Enable hammer timers. * @brief Enable hammer timers.
*/ */
#if !defined(VT_STORM_CFG_HAMMERS) || defined(__DOXYGEN__) #if !defined(VT_STORM_CFG_HAMMERS) || defined(__DOXYGEN__)
#define VT_STORM_CFG_HAMMERS TRUE #define VT_STORM_CFG_HAMMERS FALSE
#endif #endif
/** @} */ /** @} */