TIMER: Fix coscheduling to avoid a 0 delay interval

When the timer subsystem hasn't gotten fully initialized, devices may
attempt to coschedule schedule events before the clock has gotten
far enough along to be fully initialized.  When this happens we now
make sure to avoid the potential for a zero delay which will may cause
an infinite scheduling loop.
This commit is contained in:
Mark Pizzolato 2016-11-17 16:25:19 -08:00
parent 39d2944ede
commit fc3ac62218

View file

@ -89,6 +89,9 @@
#ifndef MIN #ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b)) #define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif #endif
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
//#define MS_MIN_GRANULARITY 20 //#define MS_MIN_GRANULARITY 20
#define MS_MIN_GRANULARITY 1 #define MS_MIN_GRANULARITY 1
@ -2194,7 +2197,7 @@ if (tmr == SIM_INTERNAL_CLK)
tmr = SIM_NTIMERS; tmr = SIM_NTIMERS;
else { else {
if ((tmr < 0) || (tmr >= SIM_NTIMERS)) if ((tmr < 0) || (tmr >= SIM_NTIMERS))
return sim_activate (uptr, ticks * 10000); return sim_activate (uptr, MAX(1, ticks) * 10000);
} }
if (NULL == sim_clock_unit[tmr]) if (NULL == sim_clock_unit[tmr])
return sim_activate (uptr, ticks * (rtc_currd[tmr] ? rtc_currd[tmr] : _tick_size ())); return sim_activate (uptr, ticks * (rtc_currd[tmr] ? rtc_currd[tmr] : _tick_size ()));