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:
Kevin O'Connor 2016-10-14 12:41:23 -04:00
parent 0f87493487
commit 884cee27eb
1 changed files with 11 additions and 7 deletions

View File

@ -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))
struct timer *prev;
for (;;) {
prev = pos;
if (CONFIG_MACH_AVR)
// micro optimization for AVR - reduces register pressure
asm("" : "+r"(prev) : : "memory");
pos = pos->next;
t->next = pos->next;
pos->next = t;
if (CONFIG_MACH_AVR)
// micro optimization for AVR - reduces register pressure
barrier();
if (!pos || !sched_is_before(pos->waketime, minwaketime))
break;
}
t->next = pos;
prev->next = t;
return timer_list;
}