X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fkernel%2Fao_task.c;h=03d69caab88906ca573ebd8483f3548139625c29;hb=a7e0bb5eb661cfde31c383d605cb9cb8ca568bc7;hp=55e423bb90bae9589f926ddbb3aeae690e2ad48a;hpb=4af4e36cda96d053458eeb040e35886890917385;p=fw%2Faltos diff --git a/src/kernel/ao_task.c b/src/kernel/ao_task.c index 55e423bb..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 @@ -355,7 +356,6 @@ ao_yield(void) ao_arch_naked_define */ if (ao_cur_task->wchan == NULL) ao_task_to_run_queue(ao_cur_task); - ao_cur_task = NULL; for (;;) { ao_arch_memory_barrier(); if (!ao_list_is_empty(&run_queue)) @@ -425,6 +425,7 @@ ao_sleep(__xdata void *wchan) void ao_wakeup(__xdata void *wchan) __reentrant { + ao_validate_cur_stack(); #if HAS_TASK_QUEUE struct ao_task *sleep, *next; struct ao_list *sleep_queue; @@ -442,10 +443,12 @@ ao_wakeup(__xdata void *wchan) __reentrant } ao_arch_irqrestore(flags); #else + { uint8_t i; for (i = 0; i < ao_num_tasks; i++) if (ao_tasks[i]->wchan == wchan) ao_tasks[i]->wchan = NULL; + } #endif ao_check_stack(); }