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

你好请问TI-RTOS中的任务死循环是如何理解

你好,

现在开发CC26xx系列的芯片,用的SDK例程中是包含了 TI-RTOS的。

在主函数中,有多个任务

…..

/* Kick off profile – Priority 3 */
GAPRole_createTask();

/* SDI UART Example Task – Priority 2 */
SDITask_createTask();

SPPBLEServer_createTask();

/* enable interrupts and start SYS/BIOS */
BIOS_start();

return 0;

例如其中一个函数的具体实现:

void SPPBLEServer_createTask(void)
{
Task_Params taskParams; //任务参数.

// Configure task
Task_Params_init(&taskParams); //初始化任务配置参数.
taskParams.stack = sbpTaskStack; //任务栈的指针.
taskParams.stackSize = SBP_TASK_STACK_SIZE; //任务栈的大小.
taskParams.priority = SBP_TASK_PRIORITY; //任务的优先级.1级.

Task_construct(&sbpTask, SPPBLEServer_taskFxn, &taskParams, NULL);
}

【问题1】这个Task_construct函数是会在构造任务的时候,不会立即调用 SPPBLEServer_taskFxn函数,这样理解对吗?

而是在运行到BIOS_start();后才去调用这样的 SPPBLEServer_taskFxn任务函数?

接着我们再看 SPPBLEServer_taskFxn函数的具体实现:

static void SPPBLEServer_taskFxn(UArg a0, UArg a1)
{
// Initialize application
SPPBLEServer_init(); //初始化任务。

// Application main loop
for (;;)
{
uint32_t events;

// Waits for an event to be posted associated with the calling thread.
// Note that an event associated with a thread is posted when a
// message is queued to the message receive queue of the thread

events = Event_pend(syncEvent, Event_Id_NONE, SBP_ALL_EVENTS,
ICALL_TIMEOUT_FOREVER);

…….

【问题2】这里有一个for(;;)这样的死循环,但是我们知道主函数其实还有任务,

如果【问题1】我的理解是对的,那么在构造任务的时候,就会进行死循环,

那么主函数后面其他任务如何去创建构造呢?

Viki Shi:

建议参考下这篇文章,TI RTOS的中文解析: blog.csdn.net/…/76613860

Viki Shi:

每个任务看似“死循环”,这些“死循环”可以同时执行,而调度程序会分时选择执行或结束任务

Eggsy Pang:

每个任务都可以有死循环,但是也需要有任务休眠的调用。因为任务和任务之间调度的分时是通过软件中断和硬件中断来切换的

赞(0)
未经允许不得转载:TI中文支持网 » 你好请问TI-RTOS中的任务死循环是如何理解
分享到: 更多 (0)