FreeRTOS-Kernel icon indicating copy to clipboard operation
FreeRTOS-Kernel copied to clipboard

Introduce configTRACK_TASK_MEMORY_ALLOCATIONS to track dynamic allocations per task

Open RichardBarry opened this issue 3 years ago • 6 comments

Description

Introduce configTRACK_TASK_MEMORY_ALLOCATIONS. When this is set to 1 and either heap_4 or heap_5 is used then the number of dynamic memory allocations, the number of dynamic memory frees, the total amount of heap memory allocated by a task but not yet freed (by any task), and the maximum amount of heap memory a task has ever had allocated at one time are all tracked on a task by task basis. This additional information is returned in the TaskStatus_t structure populated by the vTaskGetInfo() and the uxTaskGetSystemState() API functions.

uxBasePriority is now only included in the TaskStatus_t structure if configUSE_MUTEXES is set to 1. ulRunTimeCounter is now only included in the TaskStatus_t structure if configGENERATE_RUN_TIME_STATS is set to 1.

Update how the TCB members get initialised. Previously each member was initialised separately. Now, as there are new members, memset() the entire structure to 0 when the structure is allocated, then only explicitly initialise structure members that are not initialised to zero.

Test Steps

Add prvExerciseTaskHeapAllocationStats() to the MSVC Win32 and MPS2 QEMU IAR demos - upstreamed to the FreeRTOS/FreeRTOS repo in a separate PR.

Related Issue

The PR that adds prvExerciseTaskHeapAllocationStats() to the FreeRTOS/FreeRTOS repo.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

RichardBarry avatar Jun 14 '21 01:06 RichardBarry

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (8e2dd5b) 92.15% compared to head (2d6724e) 92.15%. Report is 350 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #353   +/-   ##
=======================================
  Coverage   92.15%   92.15%           
=======================================
  Files           4        4           
  Lines        1274     1274           
  Branches      343      343           
=======================================
  Hits         1174     1174           
  Misses         53       53           
  Partials       47       47           
Flag Coverage Δ
unittests 92.15% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jun 14 '21 01:06 codecov[bot]

Spell check is failing because of variable names. Is spell check meant to check the C code, or just the comments?

RichardBarry avatar Jun 14 '21 02:06 RichardBarry

Hi @RichardBarry I just checked with team. It looks like the current spell checker checks any line of code with comment. So if a C code line contains a comment it will check the spell of entire line inclduing the code itself. We are look for some more generic spell checker to replace the current one and hopfully can resolve the problem.

But I'm going to unblock this PR by adding exclusion of those words for now.

mingyue86010 avatar Jun 14 '21 18:06 mingyue86010

/bot run checks

mingyue86010 avatar Jun 15 '21 18:06 mingyue86010

I think this work has been done at this point? It looks like we have traceMALLOC and traceFREE calls inside of the heap files now Should this PR be closed?

Skptak avatar Sep 20 '23 19:09 Skptak

Quality Gate Failed Quality Gate failed

Failed conditions

D Reliability Rating on New Code (required ≥ A)
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

idea Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

sonarqubecloud[bot] avatar Jan 05 '24 17:01 sonarqubecloud[bot]