From 884cee27eb28f5c21aa9c3474ce8dc722e4b7c46 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 14 Oct 2016 12:41:23 -0400 Subject: [PATCH] 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 --- src/sched.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/sched.c b/src/sched.c index 450bc2c8..a5064650 100644 --- a/src/sched.c +++ b/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)) + 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; }