mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-06-10 01:55:59 +00:00
Added updated heap stats
This commit is contained in:
parent
712797ae1c
commit
1553465d2f
@ -9,16 +9,51 @@
|
|||||||
#define RTOS_DEBUG_HEAP_STATS_HPP
|
#define RTOS_DEBUG_HEAP_STATS_HPP
|
||||||
|
|
||||||
#include <sta/config.hpp>
|
#include <sta/config.hpp>
|
||||||
|
|
||||||
|
|
||||||
#ifdef STA_DEBUGGING_ENABLED
|
#ifdef STA_DEBUGGING_ENABLED
|
||||||
|
|
||||||
#include <sta/debug/debug.hpp>
|
#include <sta/debug/debug.hpp>
|
||||||
|
|
||||||
void printHeapStats();
|
namespace sta
|
||||||
|
{
|
||||||
|
namespace rtos
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief Get the free memory on the heap.
|
||||||
|
*
|
||||||
|
* @return size_t The number of free bytes on the heap.
|
||||||
|
*/
|
||||||
|
size_t getAvailableHeapSpace();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the total number of allocs during the program's
|
||||||
|
* runtime.
|
||||||
|
*
|
||||||
|
* @return size_t The number of allocs.
|
||||||
|
*/
|
||||||
|
size_t getNumAllocs();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the total number of frees during the program's
|
||||||
|
* runtime.
|
||||||
|
*
|
||||||
|
* @return size_t The number of frees.
|
||||||
|
*/
|
||||||
|
size_t getNumFrees();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Print the current heap stats
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void printHeapStats();
|
||||||
|
} // namespace rtos
|
||||||
|
} // namespace sta
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Print the current heap stats.
|
* @brief Print the current heap stats.
|
||||||
*/
|
*/
|
||||||
# define STA_DEBUG_HEAP_STATS() printHeapStats()
|
# define STA_DEBUG_HEAP_STATS() sta::rtos::printHeapStats()
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ namespace sta
|
|||||||
/**
|
/**
|
||||||
* @brief Forcibly terminate thread.
|
* @brief Forcibly terminate thread.
|
||||||
*/
|
*/
|
||||||
void terminate();
|
void kill();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Send system notification flags to thread.
|
* @brief Send system notification flags to thread.
|
||||||
|
@ -12,20 +12,52 @@
|
|||||||
#include <FreeRTOS.h>
|
#include <FreeRTOS.h>
|
||||||
#include <cmsis_os2.h>
|
#include <cmsis_os2.h>
|
||||||
|
|
||||||
void printHeapStats()
|
|
||||||
{
|
|
||||||
xHeapStats stats;
|
|
||||||
vPortGetHeapStats(&stats);
|
|
||||||
|
|
||||||
STA_DEBUG_PRINTF(
|
namespace sta
|
||||||
"[HEAP STATS] \n Available: %d\n Lowest: %d\n Mallocs: %d\n Frees: %d",
|
{
|
||||||
stats.xAvailableHeapSpaceInBytes,
|
namespace rtos
|
||||||
stats.xMinimumEverFreeBytesRemaining,
|
{
|
||||||
stats.xNumberOfSuccessfulAllocations,
|
size_t getAvailableHeapSpace()
|
||||||
stats.xNumberOfSuccessfulFrees
|
{
|
||||||
);
|
xHeapStats stats;
|
||||||
}
|
vPortGetHeapStats(&stats);
|
||||||
|
|
||||||
|
return stats.xAvailableHeapSpaceInBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t getNumAllocs()
|
||||||
|
{
|
||||||
|
xHeapStats stats;
|
||||||
|
vPortGetHeapStats(&stats);
|
||||||
|
|
||||||
|
return stats.xNumberOfSuccessfulAllocations;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t getNumFrees()
|
||||||
|
{
|
||||||
|
xHeapStats stats;
|
||||||
|
vPortGetHeapStats(&stats);
|
||||||
|
|
||||||
|
return stats.xNumberOfSuccessfulFrees;
|
||||||
|
}
|
||||||
|
|
||||||
|
void printHeapStats()
|
||||||
|
{
|
||||||
|
xHeapStats stats;
|
||||||
|
vPortGetHeapStats(&stats);
|
||||||
|
|
||||||
|
STA_DEBUG_PRINTF(
|
||||||
|
"[HEAP STATS] \n Available: %d\n Lowest: %d\n Mallocs: %d\n Frees: %d",
|
||||||
|
stats.xAvailableHeapSpaceInBytes,
|
||||||
|
stats.xMinimumEverFreeBytesRemaining,
|
||||||
|
stats.xNumberOfSuccessfulAllocations,
|
||||||
|
stats.xNumberOfSuccessfulFrees
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} // namespace rtos
|
||||||
|
} // namespace sta
|
||||||
|
|
||||||
#endif // STA_DEBUGGING_ENABLED
|
#endif // STA_DEBUGGING_ENABLED
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ namespace sta
|
|||||||
return terminate_;
|
return terminate_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtosThread::terminate()
|
void RtosThread::kill()
|
||||||
{
|
{
|
||||||
STA_ASSERT(handle_.get() != nullptr);
|
STA_ASSERT(handle_.get() != nullptr);
|
||||||
osThreadTerminate(handle_.get());
|
osThreadTerminate(handle_.get());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user