Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FreeRTOS/FreeRTOS-Kernel.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarian <32921628+Dazza0@users.noreply.github.com>2023-12-11 10:12:53 +0300
committerGitHub <noreply@github.com>2023-12-11 10:12:53 +0300
commitbd0f87c18b292f45ebf4d4b4c5bb96765465f760 (patch)
tree0b2b66bc359b3fe30bbec936b112f339d252ddaa
parent30e6b8a5eadbf61b7118c3d0ad8d205c16dfbb1c (diff)
Add portTASK_SWITCH_HOOK (#867)
This commit adds a portTASK_SWITCH_HOOK() macro which allows ports to inject behavior immediately after a context switch. For example, this macro could be used by ports that need to set an end of stack watchpoint after a context swtich. Co-authored-by: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> Co-authored-by: Soren Ptak <ptaksoren@gmail.com> Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com> Co-authored-by: Tony Josi <tonyjosi@amazon.com> Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
-rw-r--r--include/FreeRTOS.h4
-rw-r--r--tasks.c10
2 files changed, 14 insertions, 0 deletions
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 )
{