mbed-os-examples
/
mbed-os-example-mbed5-thread-statistics
Example usage of the mbed_stats_thread_get_each API.
Diff: main.cpp
- Revision:
- 0:25c062a4a1e6
- Child:
- 15:6bca4e2b1a14
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jun 05 17:34:32 2018 +0100 @@ -0,0 +1,24 @@ +#include "mbed.h" + +#if !defined(MBED_THREAD_STATS_ENABLED) +#error "Stats not enabled" +#endif + +#define MAX_THREAD_STATS 0x8 + +int main() +{ + mbed_stats_thread_t *stats = new mbed_stats_thread_t[MAX_THREAD_STATS]; + int count = mbed_stats_thread_get_each(stats, MAX_THREAD_STATS); + + for(int i = 0; i < count; i++) { + printf("ID: 0x%x \n", stats[i].id); + printf("Name: %s \n", stats[i].name); + printf("State: %d \n", stats[i].state); + printf("Priority: %d \n", stats[i].priority); + printf("Stack Size: %d \n", stats[i].stack_size); + printf("Stack Space: %d \n", stats[i].stack_space); + printf("\n"); + } + return 0; +}