@@ -831,7 +831,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
831831 if ( uxPrevCriticalNesting > 0U )
832832 {
833833 portSET_CRITICAL_NESTING_COUNT ( xCoreID , 0U );
834- portRELEASE_ISR_LOCK ();
834+ portRELEASE_ISR_LOCK ( xCoreID );
835835 }
836836 else
837837 {
@@ -840,7 +840,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
840840 mtCOVERAGE_TEST_MARKER ();
841841 }
842842
843- portRELEASE_TASK_LOCK ();
843+ portRELEASE_TASK_LOCK ( xCoreID );
844844 portMEMORY_BARRIER ();
845845 configASSERT ( pxThisTCB -> xTaskRunState == taskTASK_SCHEDULED_TO_YIELD );
846846
@@ -853,15 +853,16 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
853853 * its run state. */
854854
855855 portDISABLE_INTERRUPTS ();
856- portGET_TASK_LOCK ();
857- portGET_ISR_LOCK ();
856+
858857 xCoreID = ( BaseType_t ) portGET_CORE_ID ();
858+ portGET_TASK_LOCK ( xCoreID );
859+ portGET_ISR_LOCK ( xCoreID );
859860
860861 portSET_CRITICAL_NESTING_COUNT ( xCoreID , uxPrevCriticalNesting );
861862
862863 if ( uxPrevCriticalNesting == 0U )
863864 {
864- portRELEASE_ISR_LOCK ();
865+ portRELEASE_ISR_LOCK ( xCoreID );
865866 }
866867 }
867868 }
@@ -3854,6 +3855,7 @@ void vTaskSuspendAll( void )
38543855 #else /* #if ( configNUMBER_OF_CORES == 1 ) */
38553856 {
38563857 UBaseType_t ulState ;
3858+ BaseType_t xCoreID ;
38573859
38583860 /* This must only be called from within a task. */
38593861 portASSERT_IF_IN_ISR ();
@@ -3867,14 +3869,16 @@ void vTaskSuspendAll( void )
38673869 * uxSchedulerSuspended since that will prevent context switches. */
38683870 ulState = portSET_INTERRUPT_MASK ();
38693871
3872+ xCoreID = ( BaseType_t ) portGET_CORE_ID ();
3873+
38703874 /* This must never be called from inside a critical section. */
3871- configASSERT ( portGET_CRITICAL_NESTING_COUNT ( portGET_CORE_ID () ) == 0 );
3875+ configASSERT ( portGET_CRITICAL_NESTING_COUNT ( xCoreID ) == 0 );
38723876
38733877 /* portSOFTWARE_BARRIER() is only implemented for emulated/simulated ports that
38743878 * do not otherwise exhibit real time behaviour. */
38753879 portSOFTWARE_BARRIER ();
38763880
3877- portGET_TASK_LOCK ();
3881+ portGET_TASK_LOCK ( xCoreID );
38783882
38793883 /* uxSchedulerSuspended is increased after prvCheckForRunStateChange. The
38803884 * purpose is to prevent altering the variable when fromISR APIs are readying
@@ -3888,12 +3892,17 @@ void vTaskSuspendAll( void )
38883892 mtCOVERAGE_TEST_MARKER ();
38893893 }
38903894
3891- portGET_ISR_LOCK ();
3895+ /* Query the coreID again as prvCheckForRunStateChange may have
3896+ * caused the task to get scheduled on a different core. The correct
3897+ * task lock for the core is acquired in prvCheckForRunStateChange. */
3898+ xCoreID = ( BaseType_t ) portGET_CORE_ID ();
3899+
3900+ portGET_ISR_LOCK ( xCoreID );
38923901
38933902 /* The scheduler is suspended if uxSchedulerSuspended is non-zero. An increment
38943903 * is used to allow calls to vTaskSuspendAll() to nest. */
38953904 ++ uxSchedulerSuspended ;
3896- portRELEASE_ISR_LOCK ();
3905+ portRELEASE_ISR_LOCK ( xCoreID );
38973906
38983907 portCLEAR_INTERRUPT_MASK ( ulState );
38993908 }
@@ -3998,7 +4007,7 @@ BaseType_t xTaskResumeAll( void )
39984007 configASSERT ( uxSchedulerSuspended != 0U );
39994008
40004009 uxSchedulerSuspended = ( UBaseType_t ) ( uxSchedulerSuspended - 1U );
4001- portRELEASE_TASK_LOCK ();
4010+ portRELEASE_TASK_LOCK ( xCoreID );
40024011
40034012 if ( uxSchedulerSuspended == ( UBaseType_t ) 0U )
40044013 {
@@ -5168,8 +5177,8 @@ BaseType_t xTaskIncrementTick( void )
51685177 * and move on if another core suspended the scheduler. We should only
51695178 * do that if the current core has suspended the scheduler. */
51705179
5171- portGET_TASK_LOCK (); /* Must always acquire the task lock first. */
5172- portGET_ISR_LOCK ();
5180+ portGET_TASK_LOCK ( xCoreID ); /* Must always acquire the task lock first. */
5181+ portGET_ISR_LOCK ( xCoreID );
51735182 {
51745183 /* vTaskSwitchContext() must never be called from within a critical section.
51755184 * This is not necessarily true for single core FreeRTOS, but it is for this
@@ -5250,8 +5259,8 @@ BaseType_t xTaskIncrementTick( void )
52505259 #endif
52515260 }
52525261 }
5253- portRELEASE_ISR_LOCK ();
5254- portRELEASE_TASK_LOCK ();
5262+ portRELEASE_ISR_LOCK ( xCoreID );
5263+ portRELEASE_TASK_LOCK ( xCoreID );
52555264
52565265 traceRETURN_vTaskSwitchContext ();
52575266 }
@@ -6997,8 +7006,8 @@ static void prvResetNextTaskUnblockTime( void )
69977006 {
69987007 if ( portGET_CRITICAL_NESTING_COUNT ( xCoreID ) == 0U )
69997008 {
7000- portGET_TASK_LOCK ();
7001- portGET_ISR_LOCK ();
7009+ portGET_TASK_LOCK ( xCoreID );
7010+ portGET_ISR_LOCK ( xCoreID );
70027011 }
70037012
70047013 portINCREMENT_CRITICAL_NESTING_COUNT ( xCoreID );
@@ -7051,7 +7060,7 @@ static void prvResetNextTaskUnblockTime( void )
70517060
70527061 if ( portGET_CRITICAL_NESTING_COUNT ( xCoreID ) == 0U )
70537062 {
7054- portGET_ISR_LOCK ();
7063+ portGET_ISR_LOCK ( xCoreID );
70557064 }
70567065
70577066 portINCREMENT_CRITICAL_NESTING_COUNT ( xCoreID );
@@ -7143,8 +7152,8 @@ static void prvResetNextTaskUnblockTime( void )
71437152 /* Get the xYieldPending stats inside the critical section. */
71447153 xYieldCurrentTask = xYieldPendings [ xCoreID ];
71457154
7146- portRELEASE_ISR_LOCK ();
7147- portRELEASE_TASK_LOCK ();
7155+ portRELEASE_ISR_LOCK ( xCoreID );
7156+ portRELEASE_TASK_LOCK ( xCoreID );
71487157 portENABLE_INTERRUPTS ();
71497158
71507159 /* When a task yields in a critical section it just sets
@@ -7199,7 +7208,7 @@ static void prvResetNextTaskUnblockTime( void )
71997208
72007209 if ( portGET_CRITICAL_NESTING_COUNT ( xCoreID ) == 0U )
72017210 {
7202- portRELEASE_ISR_LOCK ();
7211+ portRELEASE_ISR_LOCK ( xCoreID );
72037212 portCLEAR_INTERRUPT_MASK_FROM_ISR ( uxSavedInterruptStatus );
72047213 }
72057214 else
0 commit comments