vTaskSuspend
[任务控制]
task. h void vTaskSuspend( TaskHandle_t xTaskToSuspend );
必须将 INCLUDE_vTaskSuspend 定义为 1 才能使用此函数。有关详细信息,请参阅 RTOS 配置文档。
暂停任意任务。无论任务优先级如何,任务被暂停后将永远无法获取任何微控制器处理时间。
对 vTaskSuspend 的调用不会累积次数,例如:若在同一任务上调用 vTaskSuspend () 两次,将仍然仅需调用一次 vTaskResume (),即可准备完毕暂停的任务。
- 参数:
-
xTaskToSuspend | 被挂起的任务句柄。传递空句柄将导致调用任务被暂停。 |
用法示例:
void vAFunction( void )
{
TaskHandle_t xHandle;
// Create a task, storing the handle.
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
// ...
// Use the handle to suspend the created task.
vTaskSuspend( xHandle );
// ...
// The created task will not run during this period, unless
// another task calls vTaskResume( xHandle ).
//...
// Suspend ourselves.
vTaskSuspend( NULL );
// We cannot get here unless another task calls vTaskResume
// with our handle as the parameter.
}
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|