Skip to content

Commit b8a2a46

Browse files
author
Cruz Monrreal
authored
Merge pull request #7545 from SenRamakri/sen_StackMaxStackIssue
Fix for Thread::max_stack not returning right value when OS_STACK_WATERMARK is enabled
2 parents d65abb6 + 481285a commit b8a2a46

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rtos/Thread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ osStatus Thread::start(Callback<void()> task) {
105105

106106
//Fill the stack with a magic word for maximum usage checking
107107
for (uint32_t i = 0; i < (_attr.stack_size / sizeof(uint32_t)); i++) {
108-
((uint32_t *)_attr.stack_mem)[i] = 0xE25A2EA5;
108+
((uint32_t *)_attr.stack_mem)[i] = osRtxStackMagicWord;
109109
}
110110

111111
memset(&_obj_mem, 0, sizeof(_obj_mem));
@@ -306,7 +306,7 @@ uint32_t Thread::max_stack() {
306306
#if defined(MBED_OS_BACKEND_RTX5)
307307
mbed_rtos_storage_thread_t *thread = (mbed_rtos_storage_thread_t *)_tid;
308308
uint32_t high_mark = 0;
309-
while (((uint32_t *)(thread->stack_mem))[high_mark] == 0xE25A2EA5)
309+
while ((((uint32_t *)(thread->stack_mem))[high_mark] == osRtxStackMagicWord) || (((uint32_t *)(thread->stack_mem))[high_mark] == osRtxStackFillPattern))
310310
high_mark++;
311311
size = thread->stack_size - (high_mark * sizeof(uint32_t));
312312
#else

0 commit comments

Comments
 (0)