vTaskSuspendAll()

michaeln32 wrote on Wednesday, February 28, 2018:

Hi,
I need to block all tasks before calling function that I wrote.

Can I use the API vTaskSuspendAll() in my application or this API is only for kernel use ?

Thank you

Michael

heinbali01 wrote on Wednesday, February 28, 2018:

vTaskSuspendAll() is for public use. It may only be called from within a normal task (not from an ISR).
xTaskResumeAll() is the opposite: it enables the scheduler.

While the scheduler is suspended, ISR’s can still occur, but they will not lead to a task switch.

Make sure that while the scheduler is suspended, you’re not calling any API that might need to block, such as API’s for queues or semaphores, or vTaskDelay().

Often the code between the two API’s is put in a compound statement, just for clarity:

vTaskSuspendAll();
{
	/* The scheduler is suspended here. */
}
xTaskResumeAll();

michaeln32 wrote on Wednesday, February 28, 2018:

Hein Thank you very much