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

@ -43,10 +43,11 @@
* In addition to the priority, flags can be used when creating a thread to
* alter the thread's behavior after creation. The following flags are available:
*
* Flags | Description
* ----------------------------- | --------------------------------------------------
* @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
* Flags | Description
* ------------------------------ | --------------------------------------------------
* @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_NO_STACKTEST| never measure the stack's memory usage
*
* Thread creation
* ===============
@ -229,6 +230,13 @@ struct _thread {
*/
#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.
*

View File

@ -265,14 +265,21 @@ kernel_pid_t thread_create(char *stack, int stacksize, uint8_t priority,
#if defined(DEVELHELP) || defined(SCHED_TEST_STACK) \
|| defined(MODULE_TEST_UTILS_PRINT_STACK_USAGE)
/* assign each int of the stack the value of it's address. Alignment
* has been handled above, so silence -Wcast-align */
uintptr_t *stackmax = (uintptr_t *)(uintptr_t)(stack + stacksize);
uintptr_t *stackp = (uintptr_t *)(uintptr_t)stack;
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
* has been handled above, so silence -Wcast-align */
uintptr_t *stackmax = (uintptr_t *)(uintptr_t)(stack + stacksize);
uintptr_t *stackp = (uintptr_t *)(uintptr_t)stack;
while (stackp < stackmax) {
*stackp = (uintptr_t)stackp;
stackp++;
while (stackp < stackmax) {
*stackp = (uintptr_t)stackp;
stackp++;
}
}
#endif