diff --git a/platform/cooja/dev/radio-arch.c b/platform/cooja/dev/radio-arch.c index 723665b34..6f6f03206 100644 --- a/platform/cooja/dev/radio-arch.c +++ b/platform/cooja/dev/radio-arch.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: radio-arch.c,v 1.3 2006/10/05 07:46:53 fros4943 Exp $ + * $Id: radio-arch.c,v 1.4 2006/10/05 12:09:40 fros4943 Exp $ */ #include "dev/radio-arch.h" @@ -68,9 +68,9 @@ doInterfaceActionsBeforeTick(void) return; } - // Busy-wait while receiving (in main file) + // Don't fall asleep while receiving (in main file) if (simReceiving) { - busyWaitNext = 1; + simDontFallAsleep = 1; return; } diff --git a/platform/cooja/lib/simEnvChange.c b/platform/cooja/lib/simEnvChange.c index 40a71d1b3..a0b918d19 100644 --- a/platform/cooja/lib/simEnvChange.c +++ b/platform/cooja/lib/simEnvChange.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: simEnvChange.c,v 1.2 2006/10/02 15:05:49 fros4943 Exp $ + * $Id: simEnvChange.c,v 1.3 2006/10/05 12:09:53 fros4943 Exp $ */ #include @@ -37,7 +37,7 @@ // All registered interfaces extern const struct simInterface *simInterfaces[]; -char busyWaitNext = 0; +char simDontFallAsleep = 0; int simProcessRunValue; int simEtimerPending; diff --git a/platform/cooja/lib/simEnvChange.h b/platform/cooja/lib/simEnvChange.h index fff92b591..9d55e329d 100644 --- a/platform/cooja/lib/simEnvChange.h +++ b/platform/cooja/lib/simEnvChange.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: simEnvChange.h,v 1.2 2006/10/02 15:05:49 fros4943 Exp $ + * $Id: simEnvChange.h,v 1.3 2006/10/05 12:09:53 fros4943 Exp $ */ #ifndef __SIMENVCHANGE_H__ @@ -43,8 +43,8 @@ extern int simProcessRunValue; extern int simEtimerPending; extern int simNextExpirationTime; -// Variable that if set to != 0, immediately yields before then next process_run() call -extern char busyWaitNext; +// Variable that when set to != 0, stops the mote from falling asleep next tick +extern char simDontFallAsleep; // Definition for registering an interface #define SIM_INTERFACE(name, doActionsBeforeTick, doActionsAfterTick) \ diff --git a/tools/cooja/config/code_main_template b/tools/cooja/config/code_main_template index 891e75530..a2ef72857 100644 --- a/tools/cooja/config/code_main_template +++ b/tools/cooja/config/code_main_template @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: code_main_template,v 1.6 2006/10/05 07:48:15 fros4943 Exp $ + * $Id: code_main_template,v 1.7 2006/10/05 12:10:12 fros4943 Exp $ */ /** @@ -116,14 +116,14 @@ start_process_run_loop(void *data) /* Always pretend we have processes left while inside process_run() */ simProcessRunValue = 1; - // Busy-wait while receiving - while (busyWaitNext > 0) { - busyWaitNext--; - cooja_mt_yield(); - } - simProcessRunValue = process_run(); + // Check if we must stay awake + if (simDontFallAsleep) { + simDontFallAsleep=0; + simProcessRunValue = 1; + } + /* Yield thread when one process_run has completed */ cooja_mt_yield(); }