TIMER: Don't consider idle calibration skipping with internal timer

As discussed in #699
This commit is contained in:
Mark Pizzolato 2019-05-30 03:23:38 -07:00
parent 0195bbda4b
commit 564ce2b3f4

View file

@ -972,18 +972,20 @@ if (delta_rtime > 30000) { /* gap too big? */
sim_debug (DBG_CAL, &sim_timer_dev, "gap too big: delta = %d - result: %d\n", delta_rtime, rtc_currd[tmr]); sim_debug (DBG_CAL, &sim_timer_dev, "gap too big: delta = %d - result: %d\n", delta_rtime, rtc_currd[tmr]);
return rtc_currd[tmr]; /* can't calibr */ return rtc_currd[tmr]; /* can't calibr */
} }
if (delta_rtime == 0) /* avoid divide by zero */ if (tmr != SIM_NTIMERS) {
last_idle_pct = 0; /* force calibration */ if (delta_rtime == 0) /* avoid divide by zero */
else last_idle_pct = 0; /* force calibration */
last_idle_pct = MIN(100, (uint32)(100.0 * (((double)(rtc_clock_time_idled[tmr] - rtc_clock_time_idled_last[tmr])) / ((double)delta_rtime)))); else
rtc_clock_time_idled_last[tmr] = rtc_clock_time_idled[tmr]; last_idle_pct = MIN(100, (uint32)(100.0 * (((double)(rtc_clock_time_idled[tmr] - rtc_clock_time_idled_last[tmr])) / ((double)delta_rtime))));
if (last_idle_pct > (100 - sim_idle_calib_pct)) { rtc_clock_time_idled_last[tmr] = rtc_clock_time_idled[tmr];
rtc_rtime[tmr] = new_rtime; /* save wall time */ if (last_idle_pct > (100 - sim_idle_calib_pct)) {
rtc_vtime[tmr] = rtc_vtime[tmr] + 1000; /* adv sim time */ rtc_rtime[tmr] = new_rtime; /* save wall time */
rtc_gtime[tmr] = sim_gtime(); /* save instruction time */ rtc_vtime[tmr] = rtc_vtime[tmr] + 1000; /* adv sim time */
++rtc_clock_calib_skip_idle[tmr]; rtc_gtime[tmr] = sim_gtime(); /* save instruction time */
sim_debug (DBG_CAL, &sim_timer_dev, "skipping calibration due to idling (%d%%) - result: %d\n", last_idle_pct, rtc_currd[tmr]); ++rtc_clock_calib_skip_idle[tmr];
return rtc_currd[tmr]; /* avoid calibrating idle checks */ sim_debug (DBG_CAL, &sim_timer_dev, "skipping calibration due to idling (%d%%) - result: %d\n", last_idle_pct, rtc_currd[tmr]);
return rtc_currd[tmr]; /* avoid calibrating idle checks */
}
} }
new_gtime = sim_gtime(); new_gtime = sim_gtime();
if ((last_idle_pct == 0) && (delta_rtime != 0)) { if ((last_idle_pct == 0) && (delta_rtime != 0)) {