ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.67k stars 2.98k forks source link

How do I get free_stack() of main thread? #5219

Closed mikevolzer-ep closed 7 years ago

mikevolzer-ep commented 7 years ago

Description


Question

How do I get the available stack of the main thread? I see there is a member function "free_stack", but I cannot find out how to get a reference to the main thread object

bulislaw commented 7 years ago

Main thread is not a C++ object, maybe we should try to wrap it in some way. For now you'll need to use RTOS API directly http://arm-software.github.io/CMSIS_5/RTOS2/html/index.html

osThreadGetStackSpace(osThreadGetId());

executed from the main thread. You'll need to add that to your build command -DMBED_STACK_STATS_ENABLED.

0Grit commented 7 years ago

@bulislaw is there an option to have an entry point before the scheduler starts?

bulislaw commented 7 years ago

Depending what you want to do, we have mbed_sdk_init but that's more for targets use, and then we have mbed_main that executes before main, but that's actually after the scheduler starts. Some more info https://github.com/ARMmbed/mbed-os/blob/master/rtos/TARGET_CORTEX/mbed_boot.c