Merge pull request #1 from chinglee-iot/update-core-id-fix

Implement get core ID with interrupt disabled
This commit is contained in:
Felix van Oost 2024-12-13 22:39:50 -05:00 committed by GitHub
commit 37c71b9d6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 54 additions and 48 deletions

View file

@ -158,10 +158,10 @@ void vYieldCore( int xCoreID );
#define portCRITICAL_NESTING_IN_TCB 0
extern UBaseType_t uxCriticalNestings[ configNUMBER_OF_CORES ];
#define portGET_CRITICAL_NESTING_COUNT() ( uxCriticalNestings[ portGET_CORE_ID() ] )
#define portSET_CRITICAL_NESTING_COUNT( x ) ( uxCriticalNestings[ portGET_CORE_ID() ] = ( x ) )
#define portINCREMENT_CRITICAL_NESTING_COUNT() ( uxCriticalNestings[ portGET_CORE_ID() ]++ )
#define portDECREMENT_CRITICAL_NESTING_COUNT() ( uxCriticalNestings[ portGET_CORE_ID() ]-- )
#define portGET_CRITICAL_NESTING_COUNT( xCoreID ) ( uxCriticalNestings[ ( xCoreID ) ] )
#define portSET_CRITICAL_NESTING_COUNT( xCoreID, x ) ( uxCriticalNestings[ ( xCoreID ) ] = ( x ) )
#define portINCREMENT_CRITICAL_NESTING_COUNT( xCoreID ) ( uxCriticalNestings[ ( xCoreID ) ]++ )
#define portDECREMENT_CRITICAL_NESTING_COUNT( xCoreID ) ( uxCriticalNestings[ ( xCoreID ) ]-- )
/*-----------------------------------------------------------*/

22
tasks.c
View file

@ -317,10 +317,10 @@
#define taskATTRIBUTE_IS_IDLE ( UBaseType_t ) ( 1U << 0U )
#if ( ( configNUMBER_OF_CORES > 1 ) && ( portCRITICAL_NESTING_IN_TCB == 1 ) )
#define portGET_CRITICAL_NESTING_COUNT( xCoreID ) ( pxCurrentTCBs[ xCoreID ]->uxCriticalNesting )
#define portSET_CRITICAL_NESTING_COUNT( xCoreID, x ) ( pxCurrentTCBs[ xCoreID ]->uxCriticalNesting = ( x ) )
#define portINCREMENT_CRITICAL_NESTING_COUNT( xCoreID ) ( pxCurrentTCBs[ xCoreID ]->uxCriticalNesting++ )
#define portDECREMENT_CRITICAL_NESTING_COUNT( xCoreID ) ( pxCurrentTCBs[ xCoreID ]->uxCriticalNesting-- )
#define portGET_CRITICAL_NESTING_COUNT( xCoreID ) ( pxCurrentTCBs[ ( xCoreID ) ]->uxCriticalNesting )
#define portSET_CRITICAL_NESTING_COUNT( xCoreID, x ) ( pxCurrentTCBs[ ( xCoreID ) ]->uxCriticalNesting = ( x ) )
#define portINCREMENT_CRITICAL_NESTING_COUNT( xCoreID ) ( pxCurrentTCBs[ ( xCoreID ) ]->uxCriticalNesting++ )
#define portDECREMENT_CRITICAL_NESTING_COUNT( xCoreID ) ( pxCurrentTCBs[ ( xCoreID ) ]->uxCriticalNesting-- )
#endif /* #if ( ( configNUMBER_OF_CORES > 1 ) && ( portCRITICAL_NESTING_IN_TCB == 1 ) ) */
#define taskBITS_PER_BYTE ( ( size_t ) 8 )
@ -6941,10 +6941,14 @@ static void prvResetNextTaskUnblockTime( void )
*/
void vTaskYieldWithinAPI( void )
{
const BaseType_t xCoreID = ( BaseType_t ) portGET_CORE_ID();
UBaseType_t ulState;
traceENTER_vTaskYieldWithinAPI();
ulState = portSET_INTERRUPT_MASK();
{
const BaseType_t xCoreID = ( BaseType_t ) portGET_CORE_ID();
if( portGET_CRITICAL_NESTING_COUNT( xCoreID ) == 0U )
{
portYIELD();
@ -6953,6 +6957,8 @@ static void prvResetNextTaskUnblockTime( void )
{
xYieldPendings[ xCoreID ] = pdTRUE;
}
}
portCLEAR_INTERRUPT_MASK( ulState );
traceRETURN_vTaskYieldWithinAPI();
}
@ -7001,7 +7007,7 @@ static void prvResetNextTaskUnblockTime( void )
traceENTER_vTaskEnterCritical();
portDISABLE_INTERRUPTS();
{
const BaseType_t xCoreID = ( BaseType_t ) portGET_CORE_ID();
if( xSchedulerRunning != pdFALSE )
@ -7038,6 +7044,7 @@ static void prvResetNextTaskUnblockTime( void )
{
mtCOVERAGE_TEST_MARKER();
}
}
traceRETURN_vTaskEnterCritical();
}
@ -7051,14 +7058,13 @@ static void prvResetNextTaskUnblockTime( void )
UBaseType_t vTaskEnterCriticalFromISR( void )
{
UBaseType_t uxSavedInterruptStatus = 0;
BaseType_t xCoreID;
const BaseType_t xCoreID = ( BaseType_t ) portGET_CORE_ID();
traceENTER_vTaskEnterCriticalFromISR();
if( xSchedulerRunning != pdFALSE )
{
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
xCoreID = ( BaseType_t ) portGET_CORE_ID();
if( portGET_CRITICAL_NESTING_COUNT( xCoreID ) == 0U )
{