SMP: are two vTaskSuspendAll()/xTaskResumeAll() regions on different cores mutually exclusive?

Hi,

On the SMP kernel, two regions bracketed by vTaskSuspendAll() / xTaskResumeAll() and running on different cores already exclude each other. In tasks.c (V11.1.0+) the configNUMBER_OF_CORES > 1 branch of vTaskSuspendAll() acquires the task lock and does not release it:

portGET_TASK_LOCK( xCoreID );
...
portGET_ISR_LOCK( xCoreID );
++uxSchedulerSuspended;
portRELEASE_ISR_LOCK( xCoreID );

xTaskResumeAll() releases it with portRELEASE_TASK_LOCK( xCoreID ), so a second core entering vTaskSuspendAll() spins on that lock until the first core resumes.

The documentation never says this. The API reference for vTaskSuspendAll(), generated from the comment block in include/task.h, says only:

Suspends the scheduler without disabling interrupts. Context switches will not occur while the scheduler is suspended.

After calling vTaskSuspendAll () the calling task will continue to execute without risk of being swapped out until a call to xTaskResumeAll () has been made.

Nothing there distinguishes cores, and the example in the same block still says “There is no need to use critical sections as we have all the microcontroller processing time”, which holds on one core only. A reader is left with no statement either way, and the safe reading of silence is to assume the weaker behaviour.

  1. Is the exclusion between suspended regions on different cores an intended and supported guarantee of the SMP kernel, or an implementation detail that may change?

  2. If it is intended, could it be documented? A possible wording for the block in include/task.h, to follow the existing paragraphs:

     * Suspending the scheduler is a valid way of obtaining mutual exclusion 
     * between tasks: two regions bracketed by vTaskSuspendAll() and 
     * TaskResumeAll() cannot overlap.
    

Thanks.

Yes, it is by design.

That is a good suggestion. Would you be willing to raise a PR for this doc update?