TI中文支持网
TI专业的中文技术问题搜集分享网站

关于SYS/BIOS 的Clock使用的问题,求教!

/*
* ======== Clock_workFunc ========
* Service Clock Queue for TickMode_PERIODIC
*/
Void Clock_workFunc(UArg arg0, UArg arg1)
{
         Queue_Elem *elem;
         UInt hwiKey, count;
         UInt32 time, compare;
         Clock_Object *obj;
         Queue_Handle clockQ;

         hwiKey = Hwi_disable();
         time = Clock_module->ticks;
         count = Clock_module->swiCount;
         Clock_module->swiCount = 0;
         Hwi_restore(hwiKey);

          /* Log when count > 1, meaning Clock_swi is delayed */
            if (count > 1) {
              Log_write1(Clock_LW_delayed, (UArg)count);
          }

         compare = time – count;

           /*
           * Here count can be zero. When Clock_tick() runs it increments
           * swiCount and posts the Clock_workFunc. In Clock_workFunc we
           * get the value of swiCount atomically. Before we read swiCount, an
           * interrupt could occur, Clock_tick() will post the swi again.
           * That post is unnecessary as we are getting ready to process that
          * tick. The next time this swi runs the count will be zero.
          */

           while (count) {

              compare = compare + 1;
              count = count – 1;

              /  * Traverse clock queue */

              clockQ = Clock_Module_State_clockQ();
              elem = Queue_head(clockQ);

              while (elem != (Queue_Elem *)(clockQ))

             {
                 obj = (Clock_Object *)elem;
                elem = Queue_next(elem);
                /* if event has timed out */
                  if ((obj->active == TRUE) && (obj->currTimeout == compare))

                 {

                if (obj->period == 0) { /* oneshot? */
                /* mark object idle */
                obj->active = FALSE;
                }
               else { /* periodic */
              /* refresh timeout */
                obj->currTimeout += obj->period;
                }

               Log_write2(Clock_LM_begin, (UArg)obj, (UArg)obj->fxn);

           /* call handler */
          obj->fxn(obj->arg);
         }
    }
  }
}

程序中调用Clock_create创建了个定时器,在使用完成后,使用Clock_stop关闭,然后程序执行其他操作,然后在没有调用任何启动定时的的情况下,程序陷入上面代码的While(count)循环中,count值很大,在5000左右,请问在什么情况下会导致该情况发生?

Jian Zhou:

上面有代码注释啊:

 Here count can be zero. When Clock_tick() runs it increments           * swiCount and posts the Clock_workFunc. In Clock_workFunc we           * get the value of swiCount atomically. Before we read swiCount, an           * interrupt could occur, Clock_tick() will post the swi again.           * That post is unnecessary as we are getting ready to process that          * tick. The next time this swi runs the count will be zero.          */

qing li3:

回复 Jian Zhou:

关键Clock已经关闭了,Clock_tick()还会增长吗?

赞(0)
未经允许不得转载:TI中文支持网 » 关于SYS/BIOS 的Clock使用的问题,求教!
分享到: 更多 (0)