Skip to content

Add portTASK_SWITCH_HOOK #867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 11, 2023
4 changes: 4 additions & 0 deletions include/FreeRTOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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 )
{
Expand Down