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:
parent
39d2944ede
commit
fc3ac62218
1 changed files with 4 additions and 1 deletions
|
@ -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 ()));
|
||||||
|
|
Loading…
Add table
Reference in a new issue