Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
|
Thread Stack APIs. More...
Macros | |
#define | K_KERNEL_STACK_DECLARE(sym, size) |
Declare a reference to a thread stack. | |
#define | K_KERNEL_STACK_ARRAY_DECLARE(sym, nmemb, size) |
Declare a reference to a thread stack array. | |
#define | K_KERNEL_PINNED_STACK_ARRAY_DECLARE(sym, nmemb, size) |
Declare a reference to a pinned thread stack array. | |
#define | K_KERNEL_STACK_DEFINE(sym, size) |
Define a toplevel kernel stack memory region. | |
#define | K_KERNEL_PINNED_STACK_DEFINE(sym, size) |
Define a toplevel kernel stack memory region in pinned section. | |
#define | K_KERNEL_STACK_ARRAY_DEFINE(sym, nmemb, size) |
Define a toplevel array of kernel stack memory regions. | |
#define | K_KERNEL_PINNED_STACK_ARRAY_DEFINE(sym, nmemb, size) |
Define a toplevel array of kernel stack memory regions in pinned section. | |
#define | K_KERNEL_STACK_MEMBER(sym, size) |
Define an embedded stack memory region. | |
#define | K_KERNEL_STACK_SIZEOF(sym) |
#define | K_THREAD_STACK_DECLARE(sym, size) |
Declare a reference to a thread stack. | |
#define | K_THREAD_STACK_ARRAY_DECLARE(sym, nmemb, size) |
Declare a reference to a thread stack array. | |
#define | K_THREAD_STACK_SIZEOF(sym) |
Return the size in bytes of a stack memory region. | |
#define | K_THREAD_STACK_DEFINE(sym, size) |
Define a toplevel thread stack memory region. | |
#define | K_THREAD_PINNED_STACK_DEFINE(sym, size) |
Define a toplevel thread stack memory region in pinned section. | |
#define | K_THREAD_STACK_LEN(size) |
Calculate size of stacks to be allocated in a stack array. | |
#define | K_THREAD_STACK_ARRAY_DEFINE(sym, nmemb, size) |
Define a toplevel array of thread stack memory regions. | |
#define | K_THREAD_PINNED_STACK_ARRAY_DEFINE(sym, nmemb, size) |
Define a toplevel array of thread stack memory regions in pinned section. | |
Thread Stack APIs
.
#define K_KERNEL_PINNED_STACK_ARRAY_DECLARE | ( | sym, | |
nmemb, | |||
size ) |
#include <zephyr/kernel/thread_stack.h>
Declare a reference to a pinned thread stack array.
This macro declares the symbol of a pinned thread stack array defined elsewhere in the current scope.
sym | Thread stack symbol name |
nmemb | Number of stacks defined |
size | Size of the stack memory region |
#define K_KERNEL_PINNED_STACK_ARRAY_DEFINE | ( | sym, | |
nmemb, | |||
size ) |
#include <zephyr/kernel/thread_stack.h>
Define a toplevel array of kernel stack memory regions in pinned section.
See K_KERNEL_STACK_ARRAY_DEFINE() for more information and constraints.
This puts the stack into the pinned noinit linker section if CONFIG_LINKER_USE_PINNED_SECTION is enabled, or else it would put the stack into the same section as K_KERNEL_STACK_ARRAY_DEFINE().
sym | Kernel stack array symbol name |
nmemb | Number of stacks to define |
size | Size of the stack memory region |
#define K_KERNEL_PINNED_STACK_DEFINE | ( | sym, | |
size ) |
#include <zephyr/kernel/thread_stack.h>
Define a toplevel kernel stack memory region in pinned section.
See K_KERNEL_STACK_DEFINE() for more information and constraints.
This puts the stack into the pinned noinit linker section if CONFIG_LINKER_USE_PINNED_SECTION is enabled, or else it would put the stack into the same section as K_KERNEL_STACK_DEFINE().
sym | Thread stack symbol name |
size | Size of the stack memory region |
#define K_KERNEL_STACK_ARRAY_DECLARE | ( | sym, | |
nmemb, | |||
size ) |
#include <zephyr/kernel/thread_stack.h>
Declare a reference to a thread stack array.
This macro declares the symbol of a thread stack array defined elsewhere in the current scope.
sym | Thread stack symbol name |
nmemb | Number of stacks defined |
size | Size of the stack memory region |
#define K_KERNEL_STACK_ARRAY_DEFINE | ( | sym, | |
nmemb, | |||
size ) |
#include <zephyr/kernel/thread_stack.h>
Define a toplevel array of kernel stack memory regions.
Stacks defined with this macro may not host user mode threads.
sym | Kernel stack array symbol name |
nmemb | Number of stacks to define |
size | Size of the stack memory region |
#define K_KERNEL_STACK_DECLARE | ( | sym, | |
size ) |
#include <zephyr/kernel/thread_stack.h>
Declare a reference to a thread stack.
This macro declares the symbol of a thread stack defined elsewhere in the current scope.
sym | Thread stack symbol name |
size | Size of the stack memory region |
#define K_KERNEL_STACK_DEFINE | ( | sym, | |
size ) |
#include <zephyr/kernel/thread_stack.h>
Define a toplevel kernel stack memory region.
This defines a region of memory for use as a thread stack, for threads that exclusively run in supervisor mode. This is also suitable for declaring special stacks for interrupt or exception handling.
Stacks defined with this macro may not host user mode threads.
It is legal to precede this definition with the 'static' keyword.
It is NOT legal to take the sizeof(sym) and pass that to the stackSize parameter of k_thread_create(), it may not be the same as the 'size' parameter. Use K_KERNEL_STACK_SIZEOF() instead.
The total amount of memory allocated may be increased to accommodate fixed-size stack overflow guards.
sym | Thread stack symbol name |
size | Size of the stack memory region |
#define K_KERNEL_STACK_MEMBER | ( | sym, | |
size ) |
#include <zephyr/kernel/thread_stack.h>
Define an embedded stack memory region.
Used for kernel stacks embedded within other data structures.
Stacks defined with this macro may not host user mode threads.
sym | Thread stack symbol name |
size | Size of the stack memory region |
#define K_KERNEL_STACK_SIZEOF | ( | sym | ) |
#include <zephyr/kernel/thread_stack.h>
#define K_THREAD_PINNED_STACK_ARRAY_DEFINE | ( | sym, | |
nmemb, | |||
size ) |
#include <zephyr/kernel/thread_stack.h>
Define a toplevel array of thread stack memory regions in pinned section.
Create an array of equally sized stacks. See K_THREAD_STACK_DEFINE definition for additional details and constraints.
This is the generic, historical definition. Align to Z_THREAD_STACK_OBJ_ALIGN and put in 'noinit' section so that it isn't zeroed at boot
This puts the stack into the pinned noinit linker section if CONFIG_LINKER_USE_PINNED_SECTION is enabled, or else it would put the stack into the same section as K_THREAD_STACK_DEFINE().
sym | Thread stack symbol name |
nmemb | Number of stacks to define |
size | Size of the stack memory region |
#define K_THREAD_PINNED_STACK_DEFINE | ( | sym, | |
size ) |
#include <zephyr/kernel/thread_stack.h>
Define a toplevel thread stack memory region in pinned section.
This defines a region of memory suitable for use as a thread's stack.
This is the generic, historical definition. Align to Z_THREAD_STACK_OBJ_ALIGN and put in 'noinit' section so that it isn't zeroed at boot
The defined symbol will always be a k_thread_stack_t which can be passed to k_thread_create(), but should otherwise not be manipulated. If the buffer inside needs to be examined, examine thread->stack_info for the associated thread object to obtain the boundaries.
It is legal to precede this definition with the 'static' keyword.
It is NOT legal to take the sizeof(sym) and pass that to the stackSize parameter of k_thread_create(), it may not be the same as the 'size' parameter. Use K_THREAD_STACK_SIZEOF() instead.
Some arches may round the size of the usable stack region up to satisfy alignment constraints. K_THREAD_STACK_SIZEOF() will return the aligned size.
This puts the stack into the pinned noinit linker section if CONFIG_LINKER_USE_PINNED_SECTION is enabled, or else it would put the stack into the same section as K_THREAD_STACK_DEFINE().
sym | Thread stack symbol name |
size | Size of the stack memory region |
#define K_THREAD_STACK_ARRAY_DECLARE | ( | sym, | |
nmemb, | |||
size ) |
#include <zephyr/kernel/thread_stack.h>
Declare a reference to a thread stack array.
This macro declares the symbol of a thread stack array defined elsewhere in the current scope.
sym | Thread stack symbol name |
nmemb | Number of stacks defined |
size | Size of the stack memory region |
#define K_THREAD_STACK_ARRAY_DEFINE | ( | sym, | |
nmemb, | |||
size ) |
#include <zephyr/kernel/thread_stack.h>
Define a toplevel array of thread stack memory regions.
Create an array of equally sized stacks. See K_THREAD_STACK_DEFINE definition for additional details and constraints.
This is the generic, historical definition. Align to Z_THREAD_STACK_OBJ_ALIGN and put in 'noinit' section so that it isn't zeroed at boot
sym | Thread stack symbol name |
nmemb | Number of stacks to define |
size | Size of the stack memory region |
#define K_THREAD_STACK_DECLARE | ( | sym, | |
size ) |
#include <zephyr/kernel/thread_stack.h>
Declare a reference to a thread stack.
This macro declares the symbol of a thread stack defined elsewhere in the current scope.
sym | Thread stack symbol name |
size | Size of the stack memory region |
#define K_THREAD_STACK_DEFINE | ( | sym, | |
size ) |
#include <zephyr/kernel/thread_stack.h>
Define a toplevel thread stack memory region.
This defines a region of memory suitable for use as a thread's stack.
This is the generic, historical definition. Align to Z_THREAD_STACK_OBJ_ALIGN and put in 'noinit' section so that it isn't zeroed at boot
The defined symbol will always be a k_thread_stack_t which can be passed to k_thread_create(), but should otherwise not be manipulated. If the buffer inside needs to be examined, examine thread->stack_info for the associated thread object to obtain the boundaries.
It is legal to precede this definition with the 'static' keyword.
It is NOT legal to take the sizeof(sym) and pass that to the stackSize parameter of k_thread_create(), it may not be the same as the 'size' parameter. Use K_THREAD_STACK_SIZEOF() instead.
Some arches may round the size of the usable stack region up to satisfy alignment constraints. K_THREAD_STACK_SIZEOF() will return the aligned size.
sym | Thread stack symbol name |
size | Size of the stack memory region |
#define K_THREAD_STACK_LEN | ( | size | ) |
#include <zephyr/kernel/thread_stack.h>
Calculate size of stacks to be allocated in a stack array.
This macro calculates the size to be allocated for the stacks inside a stack array. It accepts the indicated "size" as a parameter and if required, pads some extra bytes (e.g. for MPU scenarios). Refer K_THREAD_STACK_ARRAY_DEFINE definition to see how this is used. The returned size ensures each array member will be aligned to the required stack base alignment.
size | Size of the stack memory region |
#define K_THREAD_STACK_SIZEOF | ( | sym | ) |
#include <zephyr/kernel/thread_stack.h>
Return the size in bytes of a stack memory region.
Convenience macro for passing the desired stack size to k_thread_create() since the underlying implementation may actually create something larger (for instance a guard area).
The value returned here is not guaranteed to match the 'size' parameter passed to K_THREAD_STACK_DEFINE and may be larger, but is always safe to pass to k_thread_create() for the associated stack object.
sym | Stack memory symbol |