From 6869dc7004db1987ef290d37481cb5d1b4761db8 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Tue, 6 Sep 2016 15:14:10 +0200 Subject: [PATCH] Yield inside busywaiting loops under cooja-ip64 (nullrdc.c) The while loops waiting ACK_WAIT_TIME and AFTER_ACK_DETECTED_WAIT_TIME cause infinite loop under the cooja-ip64 platform. This is because RTIMER_NOW(), rtimer_arch_now(), has been changed not to call cooja_mt_yield() in it since rtimer was reimplemented as a higher resolution timer. In order to avoid the infinite loop, cooja_mt_yield() needs to be called inside the while loops under the platform as well as the cooja platform. --- core/net/mac/nullrdc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/net/mac/nullrdc.c b/core/net/mac/nullrdc.c index 5cec23a3d..a8d83aa66 100644 --- a/core/net/mac/nullrdc.c +++ b/core/net/mac/nullrdc.c @@ -46,10 +46,10 @@ #include "net/rime/rimestats.h" #include -#if CONTIKI_TARGET_COOJA +#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 #include "lib/simEnvChange.h" #include "sys/cooja_mt.h" -#endif /* CONTIKI_TARGET_COOJA */ +#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */ #define DEBUG 0 #if DEBUG @@ -158,10 +158,10 @@ send_one_packet(mac_callback_t sent, void *ptr) wt = RTIMER_NOW(); watchdog_periodic(); while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + ACK_WAIT_TIME)) { -#if CONTIKI_TARGET_COOJA +#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 simProcessRunValue = 1; cooja_mt_yield(); -#endif /* CONTIKI_TARGET_COOJA */ +#endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */ } ret = MAC_TX_NOACK; @@ -176,10 +176,10 @@ send_one_packet(mac_callback_t sent, void *ptr) watchdog_periodic(); while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + AFTER_ACK_DETECTED_WAIT_TIME)) { - #if CONTIKI_TARGET_COOJA + #if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 simProcessRunValue = 1; cooja_mt_yield(); - #endif /* CONTIKI_TARGET_COOJA */ + #endif /* CONTIKI_TARGET_COOJA || CONTIKI_TARGET_COOJA_IP64 */ } }