Example to demonstrate usage of mbed_stats_stack_get_each API

Fork of heap_stats_example by mbed_example

Committer:
deepikabhavnani
Date:
Thu Aug 30 16:51:05 2018 +0000
Revision:
4:539750137652
Parent:
3:c084f1df237e
Child:
5:dcc8640ad89c
Stack stats example

Who changed what in which revision?

UserRevisionLine numberNew contents of line
deepikabhavnani 0:a5479359bf28 1 #include "mbed.h"
deepikabhavnani 2:cbb9a9884f45 2 #include "mbed_stats.h"
deepikabhavnani 0:a5479359bf28 3
deepikabhavnani 2:cbb9a9884f45 4 int main(void)
deepikabhavnani 2:cbb9a9884f45 5 {
deepikabhavnani 4:539750137652 6 printf("Starting stack stats example\r\n");
deepikabhavnani 2:cbb9a9884f45 7
deepikabhavnani 4:539750137652 8 int cnt = osThreadGetCount();
deepikabhavnani 4:539750137652 9 mbed_stats_stack_t *stats = (mbed_stats_stack_t*) malloc(cnt * sizeof(mbed_stats_stack_t));
deepikabhavnani 2:cbb9a9884f45 10
deepikabhavnani 4:539750137652 11 cnt = mbed_stats_stack_get_each(stats, cnt);
deepikabhavnani 4:539750137652 12 for (int i = 0; i < cnt; i++) {
deepikabhavnani 4:539750137652 13 printf("Thread: 0x%X, Stack size: %u, Max stack: %u\r\n",
deepikabhavnani 4:539750137652 14 stats[i].thread_id, stats[i].reserved_size, stats[i].max_size);
deepikabhavnani 4:539750137652 15 }
deepikabhavnani 0:a5479359bf28 16 }