altos: Don't lose IRQ disabled state in ao_sleep
authorKeith Packard <keithp@keithp.com>
Sun, 17 Jun 2012 23:12:18 +0000 (16:12 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 17 Jun 2012 23:12:18 +0000 (16:12 -0700)
Using ao_arch_critical around the wchan setting will force interrupts
to be re-enabled before ao_yield records the state of that bit,
potentially causing problems with functions not atomically testing and
sleeping.

Tasks that need to set wchan with interrupts disabled should have
interrupts disabled when entering ao_sleep already.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/core/ao_task.c

index d7d0e8a2a493354eab8e4f051a9ded4ca0bbd4d8..910f158785fbf894dc10415d2c8bce5cfdc1352e 100644 (file)
@@ -103,9 +103,7 @@ ao_yield(void) ao_arch_naked_define
 uint8_t
 ao_sleep(__xdata void *wchan)
 {
-       ao_arch_critical(
-               ao_cur_task->wchan = wchan;
-               );
+       ao_cur_task->wchan = wchan;
        ao_yield();
        if (ao_cur_task->wchan) {
                ao_cur_task->wchan = NULL;