mirror of https://github.com/ARMmbed/mbed-os.git
stats - Added stack stats api for individual threads
Added the following - size_t mbed_stats_stack_get_each(mbed_stats_stack_t *, size_t)pull/3141/head
parent
14aa57f81c
commit
9b630b3e0d
|
@ -30,8 +30,40 @@ void mbed_stats_stack_get(mbed_stats_stack_t *stats)
|
|||
|
||||
stats->stack_cnt += 1;
|
||||
}
|
||||
#elif MBED_STACK_STATS_ENABLED
|
||||
#warning Stack statistics are not supported without the rtos.
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count)
|
||||
{
|
||||
memset(stats, 0, count*sizeof(mbed_stats_stack_t));
|
||||
size_t i = 0;
|
||||
|
||||
#if MBED_STACK_STATS_ENABLED && MBED_CONF_RTOS_PRESENT
|
||||
osThreadEnumId enumid = _osThreadsEnumStart();
|
||||
osThreadId threadid;
|
||||
|
||||
while ((threadid = _osThreadEnumNext(enumid)) && i < count) {
|
||||
osEvent e;
|
||||
|
||||
e = _osThreadGetInfo(threadid, osThreadInfoStackMax);
|
||||
if (e.status == osOK) {
|
||||
stats[i].max_size = (uint32_t)e.value.p;
|
||||
}
|
||||
|
||||
e = _osThreadGetInfo(threadid, osThreadInfoStackSize);
|
||||
if (e.status == osOK) {
|
||||
stats[i].reserved_size = (uint32_t)e.value.p;
|
||||
}
|
||||
|
||||
stats[i].thread_id = (uint32_t)threadid;
|
||||
stats[i].stack_cnt = 1;
|
||||
i += 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#if MBED_STACK_STATS_ENABLED && !MBED_CONF_RTOS_PRESENT
|
||||
#warning Stack statistics are currently not supported without the rtos.
|
||||
#endif
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#ifndef MBED_STATS_H
|
||||
#define MBED_STATS_H
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -39,6 +40,7 @@ typedef struct {
|
|||
void mbed_stats_heap_get(mbed_stats_heap_t *stats);
|
||||
|
||||
typedef struct {
|
||||
uint32_t thread_id; /**< Identifier for thread that owns the stack. */
|
||||
uint32_t max_size; /**< Sum of the maximum number of bytes used in each stack. */
|
||||
uint32_t reserved_size; /**< Current number of bytes allocated for all stacks. */
|
||||
uint32_t stack_cnt; /**< Number of stacks currently allocated. */
|
||||
|
@ -49,6 +51,12 @@ typedef struct {
|
|||
*/
|
||||
void mbed_stats_stack_get(mbed_stats_stack_t *stats);
|
||||
|
||||
/**
|
||||
* Fill the passed array of stat structures with the stack stats
|
||||
* for each available stack.
|
||||
*/
|
||||
size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue