[Thread] vTaskResume after vTaskSuspendAll

ethanjarvis wrote on Monday, November 05, 2018:

For help:
my usage is like this:

task1
{
vTaskSuspendAll();
vTaskResume(task2);
}

task2
{
xSemaphoreTake();

xSemaphoreGive();

}

but I got an assert in xSemaphoreTake();
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );

I check the code, and find that vTaskResume() will not resume the scheduler, so does it design like this, only vTaskResumeAll will resume the scheduler?

Thanks

richarddamon wrote on Monday, November 05, 2018:

vTaskSuspendAll() doesn’t suspend each task individual, but disable the scheduler, it is a form of a ‘Critical Section’ that doesn’t affect the interrupts, and thus can use a bit more time with less issues than the critical sections that disable interrrupts.

ethanjarvis wrote on Monday, November 05, 2018:

Thanks, and may I ask another question? If I suspend all task , and then vTaskResume one task, will this task run or keep suspended until vTaskResumeAll?

rtel wrote on Monday, November 05, 2018:

Thanks, and may I ask another question? If I suspend all task , and then
vTaskResume one task, will this task run or keep suspended until
vTaskResumeAll?

vTaskSuspendAll() suspends the scheduler, so you need to call
xTaskResumeAll() to unsuspend the scheduler. vTaskResume() will not
make a task run if the scheduler is suspended, and you should not make
FreeRTOS API calls when the scheduler is suspended.

ethanjarvis wrote on Tuesday, November 06, 2018:

Thanks for your answer.