diff options
author | JF002 <JF002@users.noreply.github.com> | 2020-10-04 12:21:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-04 12:21:22 +0200 |
commit | 39954bbd3afb592a0c3109e3479594183e8d0778 (patch) | |
tree | 58efd04aa38b8dc7989c51fe3c9cdb9a3fb46a54 /src/systemtask/SystemMonitor.h | |
parent | 5adc97702c326d0252df6da75ce4ac244a4b3553 (diff) | |
parent | 6c86d1d9d706706fcb6f214aba8259e61ed68755 (diff) |
Merge pull request #68 from Avamander/patch-1
Rename folders to follow a consistent style
Diffstat (limited to 'src/systemtask/SystemMonitor.h')
-rw-r--r-- | src/systemtask/SystemMonitor.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/systemtask/SystemMonitor.h b/src/systemtask/SystemMonitor.h new file mode 100644 index 00000000..ec1fd817 --- /dev/null +++ b/src/systemtask/SystemMonitor.h @@ -0,0 +1,46 @@ +#pragma once +#include <FreeRTOS.h> +#include <task.h> +#include <nrf_log.h> + + +namespace Pinetime { + namespace System { + struct DummyMonitor {}; + struct FreeRtosMonitor {}; + + template<class T> + class SystemMonitor { + public: + SystemMonitor() = delete; + }; + + template<> + class SystemMonitor<DummyMonitor> { + public: + void Process() const {} + }; + + template<> + class SystemMonitor<FreeRtosMonitor> { + public: + void Process() const { + if(xTaskGetTickCount() - lastTick > 10000) { + NRF_LOG_INFO("---------------------------------------\nFree heap : %d", xPortGetFreeHeapSize()); + auto nb = uxTaskGetSystemState(tasksStatus, 10, NULL); + for (uint32_t i = 0; i < nb; i++) { + NRF_LOG_INFO("Task [%s] - %d", tasksStatus[i].pcTaskName, tasksStatus[i].usStackHighWaterMark); + if (tasksStatus[i].usStackHighWaterMark < 20) + NRF_LOG_INFO("WARNING!!! Task %s task is nearly full, only %dB available", tasksStatus[i].pcTaskName, + tasksStatus[i].usStackHighWaterMark * 4); + } + lastTick = xTaskGetTickCount(); + } + } + + private: + mutable TickType_t lastTick = 0; + mutable TaskStatus_t tasksStatus[10]; + }; + } +}
\ No newline at end of file |