vTaskSuspend 2 Tasks
I want to suspend 2 tasks at the same time , but I cannot call vTaskSuspend twice .
example :
vTaskSuspend( Task1 );
vTaskSuspend( Task2 );
…..
vTaskResume( Task2 );
vTaskResume( Task1 );
How can I suspend 2 tasks at the same time ?
Thanks!
vTaskSuspend 2 Tasks
The API function only permits the suspension of one task at a time. If you want to atomically suspend two tasks then place the two calls in a critical section – but note this will only work if not suspending the current task as a critical section does not prevent a context switch.
Likewise, when resuming the tasks you would have to ensure that both tasks have lower priority than the task resuming them, otherwise a context switch would occur. This could be achieved by temporarily raising the priority of the calling task to above the priorities of the tasks being resumed.
Regards.