中级会员
- 积分
- 423
- 金钱
- 423
- 注册时间
- 2019-5-12
- 在线时间
- 168 小时
|
发表于 2020-2-7 09:55:47
|
显示全部楼层
本帖最后由 hejun96 于 2020-2-7 10:03 编辑
void vTaskDelay( const TickType_t xTicksToDelay )
{
BaseType_t xAlreadyYielded = pdFALSE;
//延时时间要大于0
/* A delay time of zero just forces a reschedule. */
if( xTicksToDelay > ( TickType_t ) 0U )
{
configASSERT( uxSchedulerSuspended == 0 );
vTaskSuspendAll();
{
traceTASK_DELAY();
/* A task that is removed from the event list while the
scheduler is suspended will not get placed in the ready
list or removed from the blocked list until the scheduler
is resumed.
This task cannot be in an event list as it is the currently
executing task. */
prvAddCurrentTaskToDelayedList( xTicksToDelay, pdFALSE );
}
xAlreadyYielded = xTaskResumeAll();
}
else
{
mtCOVERAGE_TEST_MARKER();
}
/* Force a reschedule if xTaskResumeAll has not already done so, we may
have put ourselves to sleep. */
if( xAlreadyYielded == pdFALSE )
{
portYIELD_WITHIN_API();
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
在task.c中vTaskDelay函数调用了vTaskSuspendAll()挂起任务调度器调用函数xTaskResumeAll()恢复任务调度器
如果函数xTaskResumeAll()没有进行任务调度的话在这里进行任务调度
|
|