From b3628902a97a6b443621cecb5321578cdee668f3 Mon Sep 17 00:00:00 2001 From: Ching-Hsin Lee Date: Tue, 9 Apr 2024 22:06:14 +0800 Subject: [PATCH] Fix vTaskSuspendAll assert for critical nesting count * Accessing the current task's TCB should be performed with interrupt disabled to ensure atomicity. --- tasks.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks.c b/tasks.c index e0db3f9e72..3c0b049baa 100644 --- a/tasks.c +++ b/tasks.c @@ -3830,9 +3830,6 @@ void vTaskSuspendAll( void ) if( xSchedulerRunning != pdFALSE ) { - /* This must never be called from inside a critical section. */ - configASSERT( portGET_CRITICAL_NESTING_COUNT() == 0 ); - /* Writes to uxSchedulerSuspended must be protected by both the task AND ISR locks. * We must disable interrupts before we grab the locks in the event that this task is * interrupted and switches context before incrementing uxSchedulerSuspended. @@ -3840,6 +3837,9 @@ void vTaskSuspendAll( void ) * uxSchedulerSuspended since that will prevent context switches. */ ulState = portSET_INTERRUPT_MASK(); + /* This must never be called from inside a critical section. */ + configASSERT( portGET_CRITICAL_NESTING_COUNT() == 0 ); + /* portSOFRWARE_BARRIER() is only implemented for emulated/simulated ports that * do not otherwise exhibit real time behaviour. */ portSOFTWARE_BARRIER();