Zephyr API Documentation
3.7.0
A Scalable Open Source RTOS
|
Macros | |
#define | K_STACK_DEFINE(name, stack_num_entries) |
Statically define and initialize a stack. | |
Functions | |
void | k_stack_init (struct k_stack *stack, stack_data_t *buffer, uint32_t num_entries) |
Initialize a stack. | |
int32_t | k_stack_alloc_init (struct k_stack *stack, uint32_t num_entries) |
Initialize a stack. | |
int | k_stack_cleanup (struct k_stack *stack) |
Release a stack's allocated buffer. | |
int | k_stack_push (struct k_stack *stack, stack_data_t data) |
Push an element onto a stack. | |
int | k_stack_pop (struct k_stack *stack, stack_data_t *data, k_timeout_t timeout) |
Pop an element from a stack. | |
#define K_STACK_DEFINE | ( | name, | |
stack_num_entries | |||
) |
#include <zephyr/kernel.h>
Statically define and initialize a stack.
The stack can be accessed outside the module where it is defined using:
name | Name of the stack. |
stack_num_entries | Maximum number of values that can be stacked. |
#include <zephyr/kernel.h>
Initialize a stack.
This routine initializes a stack object, prior to its first use. Internal buffers will be allocated from the calling thread's resource pool. This memory will be released if k_stack_cleanup() is called, or userspace is enabled and the stack object loses all references to it.
stack | Address of the stack. |
num_entries | Maximum number of values that can be stacked. |
int k_stack_cleanup | ( | struct k_stack * | stack | ) |
#include <zephyr/kernel.h>
Release a stack's allocated buffer.
If a stack object was given a dynamically allocated buffer via k_stack_alloc_init(), this will free it. This function does nothing if the buffer wasn't dynamically allocated.
stack | Address of the stack. |
0 | on success |
-EAGAIN | when object is still in use |
void k_stack_init | ( | struct k_stack * | stack, |
stack_data_t * | buffer, | ||
uint32_t | num_entries | ||
) |
#include <zephyr/kernel.h>
Initialize a stack.
This routine initializes a stack object, prior to its first use.
stack | Address of the stack. |
buffer | Address of array used to hold stacked values. |
num_entries | Maximum number of values that can be stacked. |
int k_stack_pop | ( | struct k_stack * | stack, |
stack_data_t * | data, | ||
k_timeout_t | timeout | ||
) |
#include <zephyr/kernel.h>
Pop an element from a stack.
This routine removes a stack_data_t value from stack in a "last in, first out" manner and stores the value in data.
stack | Address of the stack. |
data | Address of area to hold the value popped from the stack. |
timeout | Waiting period to obtain a value, or one of the special values K_NO_WAIT and K_FOREVER. |
0 | Element popped from stack. |
-EBUSY | Returned without waiting. |
-EAGAIN | Waiting period timed out. |
int k_stack_push | ( | struct k_stack * | stack, |
stack_data_t | data | ||
) |
#include <zephyr/kernel.h>
Push an element onto a stack.
This routine adds a stack_data_t value data to stack.
stack | Address of the stack. |
data | Value to push onto the stack. |
0 | on success |
-ENOMEM | if stack is full |