From a7e0bb5eb661cfde31c383d605cb9cb8ca568bc7 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 28 Jun 2016 17:04:59 -0700 Subject: altos: Block interrupts while waking tasks sleeping on timers. Interrupts may not be blocked in the timer ISR, but they need to be while walking the pending timer list and moving tasks back to the run queue. Signed-off-by: Keith Packard --- src/kernel/ao_task.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/kernel/ao_task.c') diff --git a/src/kernel/ao_task.c b/src/kernel/ao_task.c index e430edc6..03d69caa 100644 --- a/src/kernel/ao_task.c +++ b/src/kernel/ao_task.c @@ -165,13 +165,14 @@ ao_task_check_alarm(uint16_t tick) { struct ao_task *alarm, *next; - ao_list_for_each_entry_safe(alarm, next, &alarm_queue, struct ao_task, alarm_queue) { - if ((int16_t) (tick - alarm->alarm) < 0) - break; - alarm->alarm = 0; - ao_task_from_alarm_queue(alarm); - ao_task_to_run_queue(alarm); - } + ao_arch_critical( + ao_list_for_each_entry_safe(alarm, next, &alarm_queue, struct ao_task, alarm_queue) { + if ((int16_t) (tick - alarm->alarm) < 0) + break; + alarm->alarm = 0; + ao_task_from_alarm_queue(alarm); + ao_task_to_run_queue(alarm); + }); } void -- cgit v1.2.3