Example usage of the mbed_stats_thread_get_each API.

main.cpp

Committer:
mbed_official
Date:
2018-06-05
Revision:
0:25c062a4a1e6
Child:
15:6bca4e2b1a14

File content as of revision 0:25c062a4a1e6:

#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;
}