Example usage of the mbed_stats_thread_get_each API.

Committer:
mbed_official
Date:
Tue Jun 05 17:34:32 2018 +0100
Revision:
0:25c062a4a1e6
Child:
15:6bca4e2b1a14
Initial commit.
Commit copied from https://github.com/ARMmbed/mbed-os-example-thread-statistics

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:25c062a4a1e6 1 #include "mbed.h"
mbed_official 0:25c062a4a1e6 2
mbed_official 0:25c062a4a1e6 3 #if !defined(MBED_THREAD_STATS_ENABLED)
mbed_official 0:25c062a4a1e6 4 #error "Stats not enabled"
mbed_official 0:25c062a4a1e6 5 #endif
mbed_official 0:25c062a4a1e6 6
mbed_official 0:25c062a4a1e6 7 #define MAX_THREAD_STATS 0x8
mbed_official 0:25c062a4a1e6 8
mbed_official 0:25c062a4a1e6 9 int main()
mbed_official 0:25c062a4a1e6 10 {
mbed_official 0:25c062a4a1e6 11 mbed_stats_thread_t *stats = new mbed_stats_thread_t[MAX_THREAD_STATS];
mbed_official 0:25c062a4a1e6 12 int count = mbed_stats_thread_get_each(stats, MAX_THREAD_STATS);
mbed_official 0:25c062a4a1e6 13
mbed_official 0:25c062a4a1e6 14 for(int i = 0; i < count; i++) {
mbed_official 0:25c062a4a1e6 15 printf("ID: 0x%x \n", stats[i].id);
mbed_official 0:25c062a4a1e6 16 printf("Name: %s \n", stats[i].name);
mbed_official 0:25c062a4a1e6 17 printf("State: %d \n", stats[i].state);
mbed_official 0:25c062a4a1e6 18 printf("Priority: %d \n", stats[i].priority);
mbed_official 0:25c062a4a1e6 19 printf("Stack Size: %d \n", stats[i].stack_size);
mbed_official 0:25c062a4a1e6 20 printf("Stack Space: %d \n", stats[i].stack_space);
mbed_official 0:25c062a4a1e6 21 printf("\n");
mbed_official 0:25c062a4a1e6 22 }
mbed_official 0:25c062a4a1e6 23 return 0;
mbed_official 0:25c062a4a1e6 24 }