1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

core/thread: introduce THREAD_CREATE_NO_STACKTEST

This commit is contained in:
Benjamin Valentin 2024-07-18 16:42:52 +02:00
parent 312a550f1a
commit 0fbc10fb45
2 changed files with 26 additions and 11 deletions

View File

@ -44,9 +44,10 @@
* alter the thread's behavior after creation. The following flags are available: * alter the thread's behavior after creation. The following flags are available:
* *
* Flags | Description * Flags | Description
* ----------------------------- | -------------------------------------------------- * ------------------------------ | --------------------------------------------------
* @ref THREAD_CREATE_SLEEPING | the thread will sleep until woken up manually * @ref THREAD_CREATE_SLEEPING | the thread will sleep until woken up manually
* @ref THREAD_CREATE_WOUT_YIELD | the thread might not run immediately after creation * @ref THREAD_CREATE_WOUT_YIELD | the thread might not run immediately after creation
* @ref THREAD_CREATE_NO_STACKTEST| never measure the stack's memory usage
* *
* Thread creation * Thread creation
* =============== * ===============
@ -229,6 +230,13 @@ struct _thread {
*/ */
#define THREAD_CREATE_WOUT_YIELD (4) #define THREAD_CREATE_WOUT_YIELD (4)
/**
* @brief Never write markers into the thread's stack to measure stack usage
*
* This flag is ignored when DEVELHELP or SCHED_TEST_STACK is not enabled
*/
#define THREAD_CREATE_NO_STACKTEST (8)
/** /**
* @brief Legacy flag kept for compatibility. * @brief Legacy flag kept for compatibility.
* *

View File

@ -265,6 +265,12 @@ kernel_pid_t thread_create(char *stack, int stacksize, uint8_t priority,
#if defined(DEVELHELP) || defined(SCHED_TEST_STACK) \ #if defined(DEVELHELP) || defined(SCHED_TEST_STACK) \
|| defined(MODULE_TEST_UTILS_PRINT_STACK_USAGE) || defined(MODULE_TEST_UTILS_PRINT_STACK_USAGE)
if (flags & THREAD_CREATE_NO_STACKTEST) {
/* create stack guard. Alignment has been handled above, so silence
* -Wcast-align */
*(uintptr_t *)(uintptr_t)stack = (uintptr_t)stack;
}
else {
/* assign each int of the stack the value of it's address. Alignment /* assign each int of the stack the value of it's address. Alignment
* has been handled above, so silence -Wcast-align */ * has been handled above, so silence -Wcast-align */
uintptr_t *stackmax = (uintptr_t *)(uintptr_t)(stack + stacksize); uintptr_t *stackmax = (uintptr_t *)(uintptr_t)(stack + stacksize);
@ -274,6 +280,7 @@ kernel_pid_t thread_create(char *stack, int stacksize, uint8_t priority,
*stackp = (uintptr_t)stackp; *stackp = (uintptr_t)stackp;
stackp++; stackp++;
} }
}
#endif #endif
unsigned state = irq_disable(); unsigned state = irq_disable();