Skip to content

Commit

Permalink
Fix vTaskSuspendAll assert for critical nesting count (#1029)
Browse files Browse the repository at this point in the history
* Accessing the critical nesting count in current task's TCB is performed with interrupt disabled to ensure atomicity.
  • Loading branch information
chinglee-iot authored Apr 11, 2024
1 parent 73851fb commit 4d4f8d0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -3831,16 +3831,16 @@ 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.
* It is safe to re-enable interrupts after releasing the ISR lock and incrementing
* 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();
Expand Down

0 comments on commit 4d4f8d0

Please sign in to comment.