From: idgay Date: Wed, 23 Jul 2008 17:25:42 +0000 (+0000) Subject: Remove need for volatiles in scheduler by fixing McuSleep.sleep to tell X-Git-Tag: release_tinyos_2_1_0_0~42 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=d0ac870a232fc232fb630ad64874aadbf1b244a6 Remove need for volatiles in scheduler by fixing McuSleep.sleep to tell system that memory may change when interrupts are enabled --- diff --git a/tos/chips/atm128/McuSleepC.nc b/tos/chips/atm128/McuSleepC.nc index 9d03201e..a7c7433a 100644 --- a/tos/chips/atm128/McuSleepC.nc +++ b/tos/chips/atm128/McuSleepC.nc @@ -102,7 +102,8 @@ implementation { (MCUCR & 0xe3) | 1 << SE | read_uint8_t(&atm128PowerBits[powerState]); sei(); - asm volatile ("sleep"); + // All of memory may change at this point... + asm volatile ("sleep" : : : "memory"); cli(); } diff --git a/tos/chips/atm128/sim/McuSleepC.nc b/tos/chips/atm128/sim/McuSleepC.nc index 5919ea19..2344bc99 100644 --- a/tos/chips/atm128/sim/McuSleepC.nc +++ b/tos/chips/atm128/sim/McuSleepC.nc @@ -110,7 +110,8 @@ implementation { MCUCR = temp; } sei(); - asm volatile ("sleep"); + // All of memory may change at this point... + asm volatile ("sleep" : : : "memory"); cli(); } diff --git a/tos/chips/atm1281/McuSleepC.nc b/tos/chips/atm1281/McuSleepC.nc index ad4a4ab0..19b8738c 100644 --- a/tos/chips/atm1281/McuSleepC.nc +++ b/tos/chips/atm1281/McuSleepC.nc @@ -132,7 +132,8 @@ implementation { SMCR = (SMCR & 0xf0) | 1 << SE | read_uint8_t(&atm128PowerBits[powerState]); sei(); - asm volatile ("sleep"); + // All of memory may change at this point... + asm volatile ("sleep" : : : "memory"); cli(); CLR_BIT(SMCR, SE); diff --git a/tos/chips/msp430/McuSleepC.nc b/tos/chips/msp430/McuSleepC.nc index 369737c8..504e9add 100644 --- a/tos/chips/msp430/McuSleepC.nc +++ b/tos/chips/msp430/McuSleepC.nc @@ -114,6 +114,8 @@ implementation { } temp = msp430PowerBits[powerState] | SR_GIE; __asm__ __volatile__( "bis %0, r2" : : "m" (temp) ); + // All of memory may change at this point... + asm volatile ("" : : : "memory"); __nesc_disable_interrupt(); } diff --git a/tos/chips/pxa27x/McuSleepC.nc b/tos/chips/pxa27x/McuSleepC.nc index 85d6864f..45f98c7e 100644 --- a/tos/chips/pxa27x/McuSleepC.nc +++ b/tos/chips/pxa27x/McuSleepC.nc @@ -58,6 +58,8 @@ implementation { : "r" (PWRMODE_M_IDLE) ); __nesc_enable_interrupt(); + // All of memory may change at this point... + asm volatile ("" : : : "memory"); __nesc_disable_interrupt(); return; } diff --git a/tos/system/SchedulerBasicP.nc b/tos/system/SchedulerBasicP.nc index d80968ed..9f99fd66 100644 --- a/tos/system/SchedulerBasicP.nc +++ b/tos/system/SchedulerBasicP.nc @@ -53,9 +53,11 @@ implementation NO_TASK = 255, }; - volatile uint8_t m_head; - volatile uint8_t m_tail; - volatile uint8_t m_next[NUM_TASKS]; + uint8_t m_head; + uint8_t m_tail; + uint8_t m_next[NUM_TASKS]; + +#define v_head (*(volatile uint8_t *)&m_head) // Helper functions (internal functions) intentionally do not have atomic // sections. It is left as the duty of the exported interface functions to