xTaskCatchUpTicks
[RTOS 内核控制]
task.h
BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp );
在应用程序代码长时间禁用中断后,
更正滴答计数值。
此函数与
vTaskStepTick() 类似,
但与
vTaskStepTick() 不同的是,此函数可以增加滴答计数,
使其超过应将任务从阻塞态中移除的时间。这意味着 xTaskCatchUpTicks() 可从
阻塞态中移除任务。
- 参数:
-
xTicksToCatchUp
|
由于中断被禁用而错过的滴答中断数。
此值不会自动计算,
必须由应用程序编写者计算。
|
- 返回:
- 如果增加滴答计数,任务会解除阻塞态并执行上下文切换,
则返回 pdTRUE。 否则返回 pdFALSE。
用法示例:
void vExampleFunction( void )
{
unsigned long ulTimeBefore, ulTimeAfter;
/* Read the current time before arbitrary processing takes place. */
ulTimeBefore = ulGetExternalTime();
/* Stop the timer that is generating the tick interrupt. */
prvStopTickInterruptTimer();
/* Perform some arbitrary processing. */
arbitrary_processing();
/* Read the current time for computing elapsed time since ticks
were disabled. */
ulTimeAfter = ulGetExternalTime();
if ( xTaskCatchUpTicks( ulTimeAfter - ulTimeBefore ) == pdTRUE )
{
/* Moving the tick count forward resulted in a context switch. */
}
/* Restart the timer that is generating the tick interrupt. */
prvStartTickInterruptTimer();
}
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.