Skip to content
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

Improve multiple accessing pxCurrentTCB in a function #1065

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d4b8bfd
First version of pxCurrentTCB
chinglee-iot May 20, 2024
edfa323
Update the usage of pxCurrentTCB
chinglee-iot May 20, 2024
5e2227f
Merge branch 'main' into update-pxcurrentTCB
chinglee-iot May 20, 2024
b2f9dad
Refine the implementation
chinglee-iot May 20, 2024
028ccda
Merge branch 'main' into update-pxcurrentTCB
chinglee-iot May 20, 2024
bade1a6
Fix typo
chinglee-iot May 20, 2024
c774dfd
Revert select highest priority task
chinglee-iot May 20, 2024
69581fa
Fix compiler error
chinglee-iot May 20, 2024
080b840
Update pxCurrentTCB
chinglee-iot May 20, 2024
1c9130f
Update usage again
chinglee-iot May 20, 2024
8200e59
Remove pxCurrentTCB define in SMP
chinglee-iot May 20, 2024
2883653
Update for performance
chinglee-iot May 21, 2024
f08c3c5
Use unsafe get in critical section directory
chinglee-iot Jul 8, 2024
f4dad5e
Merge remote-tracking branch 'freertos/main' into update-pxcurrentTCB
chinglee-iot Jul 8, 2024
67b6574
Update pxCurrentTCBs[ portGET_CORE_ID() ] optimization
chinglee-iot Jul 8, 2024
4ec5b9d
Update set current TCB
chinglee-iot Jul 8, 2024
cb0b1ed
code refine
chinglee-iot Jul 8, 2024
9362ac4
Remove set current TCB
chinglee-iot Jul 8, 2024
0fcb04a
Refine usage
chinglee-iot Jul 8, 2024
98faa78
Fix typo
chinglee-iot Jul 8, 2024
9a097c5
Fix typo
chinglee-iot Jul 8, 2024
7a418ce
Fix format and spelling
chinglee-iot Jul 8, 2024
f41b6a6
Fix typo in xHigherPriorityReadyTasks
chinglee-iot Jul 8, 2024
dded3f4
Update typo
chinglee-iot Jul 8, 2024
e43f7d8
Update variable name
chinglee-iot Jul 8, 2024
926224e
Rename prvGetCurrentTaskTCB to prvGetCurrentTCB
chinglee-iot Jul 8, 2024
937dcf1
Update format
chinglee-iot Jul 8, 2024
b7e9b2d
Rename function name
chinglee-iot Jul 8, 2024
893fcc8
Merge branch 'main' into update-pxcurrentTCB
chinglee-iot Aug 6, 2024
ba2306d
Merge branch 'main' into update-pxcurrentTCB
chinglee-iot Aug 20, 2024
cd0d09c
Merge branch 'main' into update-pxcurrentTCB
chinglee-iot Aug 26, 2024
730ae6b
Merge branch 'main' into update-pxcurrentTCB
aggarg Aug 30, 2024
ab84561
Merge branch 'main' into update-pxcurrentTCB
aggarg Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 38 additions & 33 deletions include/stack_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@
#if ( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH < 0 ) )

/* Only the current stack state is to be checked. */
#define taskCHECK_FOR_STACK_OVERFLOW() \
do { \
/* Is the currently saved stack pointer within the stack limit? */ \
if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack + portSTACK_LIMIT_PADDING ) \
{ \
char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
} \
#define taskCHECK_FOR_STACK_OVERFLOW() \
do { \
TCB_t * const pxConstCurrentTCB = prvGetCurrentTCBUnsafe(); \
\
/* Is the currently saved stack pointer within the stack limit? */ \
if( pxConstCurrentTCB->pxTopOfStack <= pxConstCurrentTCB->pxStack + portSTACK_LIMIT_PADDING ) \
{ \
char * pcOverflowTaskName = pxConstCurrentTCB->pcTaskName; \
vApplicationStackOverflowHook( ( TaskHandle_t ) pxConstCurrentTCB, pcOverflowTaskName ); \
} \
} while( 0 )

#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
Expand All @@ -72,35 +74,37 @@
#if ( ( configCHECK_FOR_STACK_OVERFLOW == 1 ) && ( portSTACK_GROWTH > 0 ) )

/* Only the current stack state is to be checked. */
#define taskCHECK_FOR_STACK_OVERFLOW() \
do { \
\
/* Is the currently saved stack pointer within the stack limit? */ \
if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) \
{ \
char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
} \
#define taskCHECK_FOR_STACK_OVERFLOW() \
do { \
TCB_t * const pxConstCurrentTCB = prvGetCurrentTCBUnsafe(); \
\
/* Is the currently saved stack pointer within the stack limit? */ \
if( pxConstCurrentTCB->pxTopOfStack >= pxConstCurrentTCB->pxEndOfStack - portSTACK_LIMIT_PADDING ) \
{ \
char * pcOverflowTaskName = pxConstCurrentTCB->pcTaskName; \
vApplicationStackOverflowHook( ( TaskHandle_t ) pxConstCurrentTCB, pcOverflowTaskName ); \
} \
} while( 0 )

#endif /* configCHECK_FOR_STACK_OVERFLOW == 1 */
/*-----------------------------------------------------------*/

#if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) )

#define taskCHECK_FOR_STACK_OVERFLOW() \
do { \
const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \
const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5U; \
\
if( ( pulStack[ 0 ] != ulCheckValue ) || \
( pulStack[ 1 ] != ulCheckValue ) || \
( pulStack[ 2 ] != ulCheckValue ) || \
( pulStack[ 3 ] != ulCheckValue ) ) \
{ \
char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
} \
#define taskCHECK_FOR_STACK_OVERFLOW() \
do { \
TCB_t * const pxConstCurrentTCB = prvGetCurrentTCBUnsafe(); \
const uint32_t * const pulStack = ( uint32_t * ) pxConstCurrentTCB->pxStack; \
const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5U; \
\
if( ( pulStack[ 0 ] != ulCheckValue ) || \
( pulStack[ 1 ] != ulCheckValue ) || \
( pulStack[ 2 ] != ulCheckValue ) || \
( pulStack[ 3 ] != ulCheckValue ) ) \
{ \
char * pcOverflowTaskName = pxConstCurrentTCB->pcTaskName; \
vApplicationStackOverflowHook( ( TaskHandle_t ) pxConstCurrentTCB, pcOverflowTaskName ); \
} \
} while( 0 )

#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
Expand All @@ -110,7 +114,8 @@

#define taskCHECK_FOR_STACK_OVERFLOW() \
do { \
int8_t * pcEndOfStack = ( int8_t * ) pxCurrentTCB->pxEndOfStack; \
TCB_t * const pxConstCurrentTCB = prvGetCurrentTCBUnsafe(); \
int8_t * pcEndOfStack = ( int8_t * ) pxConstCurrentTCB->pxEndOfStack; \
static const uint8_t ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \
Expand All @@ -123,8 +128,8 @@
/* Has the extremity of the task stack ever been written over? */ \
if( memcmp( ( void * ) pcEndOfStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \
{ \
char * pcOverflowTaskName = pxCurrentTCB->pcTaskName; \
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pcOverflowTaskName ); \
char * pcOverflowTaskName = pxConstCurrentTCB->pcTaskName; \
vApplicationStackOverflowHook( ( TaskHandle_t ) pxConstCurrentTCB, pcOverflowTaskName ); \
} \
} while( 0 )

Expand Down
Loading
Loading