mirror of https://github.com/Desuuuu/klipper.git
sched: Improve AVR optimization of reschedule_timer()
Tweak the AVR register pressure optimization in reschedule_timer() to optimize it further. This improves the performance of AVR timers when there are several pending timers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
0f87493487
commit
884cee27eb
16
src/sched.c
16
src/sched.c
|
@ -136,14 +136,18 @@ reschedule_timer(struct timer *t)
|
|||
|
||||
// Find new timer position and update list
|
||||
timer_list = pos;
|
||||
while (pos->next && sched_is_before(pos->next->waketime, minwaketime))
|
||||
pos = pos->next;
|
||||
t->next = pos->next;
|
||||
pos->next = t;
|
||||
|
||||
struct timer *prev;
|
||||
for (;;) {
|
||||
prev = pos;
|
||||
if (CONFIG_MACH_AVR)
|
||||
// micro optimization for AVR - reduces register pressure
|
||||
barrier();
|
||||
asm("" : "+r"(prev) : : "memory");
|
||||
pos = pos->next;
|
||||
if (!pos || !sched_is_before(pos->waketime, minwaketime))
|
||||
break;
|
||||
}
|
||||
t->next = pos;
|
||||
prev->next = t;
|
||||
return timer_list;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue