Example to demonstrate usage of mbed_stats_stack_get_each API

Fork of heap_stats_example by mbed_example

main.cpp

Committer:
deepikabhavnani
Date:
2018-08-30
Revision:
4:539750137652
Parent:
3:c084f1df237e
Child:
5:dcc8640ad89c

File content as of revision 4:539750137652:

#include "mbed.h"
#include "mbed_stats.h"

int main(void)
{
    printf("Starting stack stats example\r\n");

    int cnt = osThreadGetCount();
    mbed_stats_stack_t *stats = (mbed_stats_stack_t*) malloc(cnt * sizeof(mbed_stats_stack_t));

    cnt = mbed_stats_stack_get_each(stats, cnt);
    for (int i = 0; i < cnt; i++) {
        printf("Thread: 0x%X, Stack size: %u, Max stack: %u\r\n", 
                stats[i].thread_id, stats[i].reserved_size, stats[i].max_size);
    }
}