diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-08-07 12:33:08 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-08-08 00:27:28 -0400 |
commit | 2c272f99a3fac49d8acd4b49a1aa3302225f17b8 (patch) | |
tree | 07998c722ed20fa812de26e1941daf57a030271f /src/generic/timer_irq.c | |
parent | a9982beacf184ccdc4bf1221852c900b0809537d (diff) | |
download | kutter-2c272f99a3fac49d8acd4b49a1aa3302225f17b8.tar.gz kutter-2c272f99a3fac49d8acd4b49a1aa3302225f17b8.tar.xz kutter-2c272f99a3fac49d8acd4b49a1aa3302225f17b8.zip |
sched: Implement generic sleep mechanism based on tasks pending
Track when tasks are pending and spin in irq_wait() when no tasks are
pending. This improves the mechanism for sleeping the processor -
it's simpler for the board specific code and it reduces the
possibility of the processor sleeping when tasks are busy.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/generic/timer_irq.c')
-rw-r--r-- | src/generic/timer_irq.c | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/src/generic/timer_irq.c b/src/generic/timer_irq.c index 605fc129..03881b2e 100644 --- a/src/generic/timer_irq.c +++ b/src/generic/timer_irq.c @@ -8,7 +8,6 @@ #include "board/irq.h" // irq_disable #include "board/misc.h" // timer_from_us #include "board/timer_irq.h" // timer_dispatch_many -#include "basecmd.h" // stats_note_sleep #include "command.h" // shutdown #include "sched.h" // sched_timer_dispatch @@ -80,23 +79,9 @@ timer_dispatch_many(void) void timer_task(void) { - static uint32_t last_timer; - uint32_t lst = last_timer; irq_disable(); - uint32_t next = timer_get_next(), cur = timer_read_time(); - if (lst != next) { - timer_repeat_until = cur + TIMER_IDLE_REPEAT_TICKS; - irq_enable(); - last_timer = next; - return; - } - - // Sleep the processor - irq_wait(); - uint32_t post_sleep = timer_read_time(); - timer_repeat_until = post_sleep + TIMER_IDLE_REPEAT_TICKS; + timer_repeat_until = timer_read_time() + TIMER_IDLE_REPEAT_TICKS; irq_enable(); - stats_note_sleep(post_sleep - cur); } DECL_TASK(timer_task); |