Hi,
Is there any way to get information about stack and heap at runtime in a C function? I'm looking for a var/table/way to get Stack_Base, Heap_base, Stack_limit and heap_limit at runtime.
That's because I'm trying to make a very very small multitasking kernel for Cortex-M3 and I need somehow to know the Stack memory avail for my alloc routines.
Regards,
Christos Houtouridis, Electrical Engineer
Again - you don't seem to have read the above comments very well - there is no real advantage in having a configuration indicating the amount of memory avail to the kernel. Now rewind, read this sentence once again (exit infinite loop). You don't need this if you allocate all the memory you need in compile time - end of discussion. What is the problem?
Dear Tamir,
There is no problem with that. I just want to avoid the "compile time alloc" thing. Of-course if I can not find a solution i'll use something like that
uint8_t kstack_privil[KERNEL_PRIVILEGED_STACK_SIZE]; uint8_t kstack_unprivil[KERNEL_UNPRIVILEGED_STACK_SIZE];
And I'll make the allocator to give stack slices from these tables.
Christos.
You can always allocate memory from the heap. But remember that systems that are built using such a kernel will require the have heap space allocated as well.