diff --git a/include/FreeRTOS.h b/include/FreeRTOS.h index b6caec77f..23526bb02 100644 --- a/include/FreeRTOS.h +++ b/include/FreeRTOS.h @@ -529,6 +529,10 @@ #define portSETUP_TCB( pxTCB ) ( void ) ( pxTCB ) #endif +#ifndef portTASK_SWITCH_HOOK + #define portTASK_SWITCH_HOOK( pxTCB ) ( void ) ( pxTCB ) +#endif + #ifndef configQUEUE_REGISTRY_SIZE #define configQUEUE_REGISTRY_SIZE 0U #endif diff --git a/tasks.c b/tasks.c index a19ab9195..ccafc1e25 100644 --- a/tasks.c +++ b/tasks.c @@ -5153,6 +5153,11 @@ BaseType_t xTaskIncrementTick( void ) taskSELECT_HIGHEST_PRIORITY_TASK(); traceTASK_SWITCHED_IN(); + /* Macro to inject port specific behaviour immediately after + * switching tasks, such as setting an end of stack watchpoint + * or reconfiguring the MPU. */ + portTASK_SWITCH_HOOK( pxCurrentTCB ); + /* After the new task is switched in, update the global errno. */ #if ( configUSE_POSIX_ERRNO == 1 ) { @@ -5245,6 +5250,11 @@ BaseType_t xTaskIncrementTick( void ) taskSELECT_HIGHEST_PRIORITY_TASK( xCoreID ); traceTASK_SWITCHED_IN(); + /* Macro to inject port specific behaviour immediately after + * switching tasks, such as setting an end of stack watchpoint + * or reconfiguring the MPU. */ + portTASK_SWITCH_HOOK( pxCurrentTCBs[ portGET_CORE_ID() ] ); + /* After the new task is switched in, update the global errno. */ #if ( configUSE_POSIX_ERRNO == 1 ) {