[Tinyos-help] confusing with the sleep atomic block

张荣雨 zhangrongyu at yahoo.cn
Fri Jul 24 00:50:47 PDT 2009


Hi,
I used to record the moment the CPU go to sleep and wake up,and compute the sleep time and wake up time.And in the task loop the code like this:

      atomic
      {
 while ((nextTask = popTask()) == NO_TASK)
 {
  sleep_Flag =TRUE;                        /////////////////////
  s_Moment = call LocalTime.get();  
    call McuSleep.sleep();
   }
      }
     atomic
     {
 oldFlag = sleep_Flag;
  sleep_Flag =FALSE;
     }
    if(oldFlag)
     {
 active_Time += s_Moment - w_Moment;
 w_Moment = call LocalTime.get();     //
 sleep_Time += w_Moment - s_Moment;
    }
 
The result appers that the active time is two times as great as the sleep time,and it seems incorrect.And when I put the code int the MCUSleep atomic block as this:
 
    atomic
      {
 while ((nextTask = popTask()) == NO_TASK)
 {
  s_Moment = call LocalTime.get();   
  active_Time += s_Moment - w_Moment;
   call McuSleep.sleep();
   w_Moment = call LocalTime.get();     //
   sleep_Time += w_Moment - s_Moment;
 }
      }
the result seems the active time very small.And I'am confusing with the huge difference between them.
1) Why they are so different?In my mind It should be the some.
2)Without finishing the atomic block,can the CPU go to sleep?
 
Thanks for any help.
 


      ___________________________________________________________ 
  好玩贺卡等你发,邮箱贺卡全新上线! 
http://card.mail.cn.yahoo.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20090724/96dcabe5/attachment.htm 


More information about the Tinyos-help mailing list