Bob's optimizations.
@@ -60,7 +60,6 @@ | ||
60 | 60 | */ |
61 | 61 | static void vt_set_alarm(systime_t basetime, sysinterval_t delta) { |
62 | 62 | sysinterval_t mindelta; |
63 | - systime_t next_alarm; | |
64 | 63 | |
65 | 64 | /* Initial delta is what is configured statically.*/ |
66 | 65 | mindelta = (sysinterval_t)CH_CFG_ST_TIMEDELTA; |
@@ -82,11 +81,8 @@ | ||
82 | 81 | sysinterval_t nowdelta; |
83 | 82 | systime_t now; |
84 | 83 | |
85 | - /* Absolute time for next alarm.*/ | |
86 | - next_alarm = chTimeAddX(basetime, delta); | |
87 | - | |
88 | 84 | /* Setting up the alarm on the next deadline.*/ |
89 | - port_timer_set_alarm(next_alarm); | |
85 | + port_timer_set_alarm(chTimeAddX(basetime, delta)); | |
90 | 86 | |
91 | 87 | /* Check on current time, we need to detect the error condition where |
92 | 88 | current time skipped past the calculated deadline.*/ |
@@ -149,7 +145,6 @@ | ||
149 | 145 | */ |
150 | 146 | static void vt_enqueue(virtual_timers_list_t *vtlp, |
151 | 147 | virtual_timer_t *vtp, |
152 | - systime_t now, | |
153 | 148 | sysinterval_t delay) { |
154 | 149 | sysinterval_t delta; |
155 | 150 |
@@ -156,6 +151,7 @@ | ||
156 | 151 | #if CH_CFG_ST_TIMEDELTA > 0 |
157 | 152 | { |
158 | 153 | sysinterval_t nowdelta; |
154 | + systime_t now = chVTGetSystemTimeX(); | |
159 | 155 | |
160 | 156 | /* Special case where the timers list is empty.*/ |
161 | 157 | if (ch_dlist_isempty(&vtlp->dlist)) { |
@@ -185,7 +181,6 @@ | ||
185 | 181 | } |
186 | 182 | } |
187 | 183 | #else /* CH_CFG_ST_TIMEDELTA == 0 */ |
188 | - (void)now; | |
189 | 184 | |
190 | 185 | /* Delta is initially equal to the specified delay.*/ |
191 | 186 | delta = delay; |
@@ -233,7 +228,7 @@ | ||
233 | 228 | vtp->reload = (sysinterval_t)0; |
234 | 229 | |
235 | 230 | /* Inserting the timer in the delta list.*/ |
236 | - vt_enqueue(vtlp, vtp, chVTGetSystemTimeX(), delay); | |
231 | + vt_enqueue(vtlp, vtp, delay); | |
237 | 232 | } |
238 | 233 | |
239 | 234 | /** |
@@ -271,7 +266,7 @@ | ||
271 | 266 | vtp->reload = delay; |
272 | 267 | |
273 | 268 | /* Inserting the timer in the delta list.*/ |
274 | - vt_enqueue(vtlp, vtp, chVTGetSystemTimeX(), delay); | |
269 | + vt_enqueue(vtlp, vtp, delay); | |
275 | 270 | } |
276 | 271 | |
277 | 272 | /** |
@@ -481,14 +476,13 @@ | ||
481 | 476 | chSysUnlockFromISR(); |
482 | 477 | vtp->func(vtp, vtp->par); |
483 | 478 | chSysLockFromISR(); |
484 | - | |
479 | + now = chVTGetSystemTimeX(); | |
485 | 480 | /* If a reload is defined the timer needs to be restarted.*/ |
486 | 481 | if (unlikely(vtp->reload > (sysinterval_t)0)) { |
487 | 482 | sysinterval_t delay; |
488 | 483 | |
489 | - /* Refreshing the current time after spending time in the callback for | |
484 | + /* Refreshing the now delta after spending time in the callback for | |
490 | 485 | a more accurate detection of too fast reloads.*/ |
491 | - now = chVTGetSystemTimeX(); | |
492 | 486 | nowdelta = chTimeDiffX(lasttime, now); |
493 | 487 | |
494 | 488 | #if !defined(CH_VT_RFCU_DISABLED) |