Quantcast
Channel: Zigbee 和 Thread
Viewing all articles
Browse latest Browse all 16962

帖子: RE: Zstack协议栈中如何确定任务优先级?

$
0
0

OSAL.C里osal_run_system( void )这个函数就是处理所有事件的。

...

uint8 idx = 0;

do {
if (tasksEvents[idx]) // Task is highest priority that is ready.
{
break;
}
} while (++idx < tasksCnt);

...

这段意思就是idx从0号任务至tasksCnt号任务挨个找,哪个号有任务就break出去执行这个任务。

这个任务号顺序是固定的,如下:

const pTaskEventHandlerFn tasksArr[] = {
macEventLoop,
nwk_event_loop,
Hal_ProcessEvent,
#if defined( MT_TASK )
MT_ProcessEvent,
#endif
APS_event_loop,
#if defined ( ZIGBEE_FRAGMENTATION )
APSF_ProcessEvent,
#endif
ZDApp_event_loop,
#if defined ( ZIGBEE_FREQ_AGILITY ) || defined ( ZIGBEE_PANID_CONFLICT )
ZDNwkMgr_event_loop,
#endif

SAPI_ProcessEvent
};

const uint8 tasksCnt = sizeof( tasksArr ) / sizeof( tasksArr[0] );

可以看到macEventLoop是第一号任务,SAPI_ProcessEvent(用户应用)是最后一号任务;系统顺序查询这些任务号有没有需要执行的任务,这就是轮询。

不知道说明白没,你在研究下


Viewing all articles
Browse latest Browse all 16962

Trending Articles