I am new in this and I want to start to use FreeRtos. I seen that statically memory allocation is done by an array and depth is in bytes and not words. But array is of type StackType_t
Example says:
#define STACK_SIZE 200
...
// Buffer that the task being created will use as its stack. Note this is
// an array of StackType_t variables. The size of StackType_t is dependent on
// the RTOS port.
StackType_t xStack[ STACK_SIZE ];
So depends on port in this case Esp32.
Index of the array and depth are both in bytes. I am asking if it have to be
ARRAY_INDEX = STACK SIZE / sizeof(* StackType_t)
Or if size Stacktype_t = 1 byte.
Many thanks in advance for your comments.
Array for memory allocation in FreeRtos
-
MicroController
- Posts: 2663
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Array for memory allocation in FreeRtos
Yes, stack_size_bytes = stack_depth * sizeof( StackType_t ) and stack_depth = stack_size_bytes / sizeof( StackType_t ).
So you'd usually
But with the ESP-IDF it doesn't really matter because sizeof( StackType_t ) == 1.
So you'd usually
Code: Select all
#define STACK_SIZE (4*1024) // 4kB
StackType_t the_stack[ STACK_SIZE / sizeof( StackType_t ) ];
Who is online
Users browsing this forum: Amazon [Bot], ChatGPT-User, PerplexityBot and 6 guests