Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[electron, gen3] Temporarily increase IDLE task priority whenever a thread exits (calls vTaskDelete) #1862

Merged
merged 2 commits into from Jul 25, 2019

Conversation

@avtolstoy
Copy link
Member

commented Jul 23, 2019

Problem

Due to the busy-loop nature of the application thread and higher priority (2) FreeRTOS IDLE thread responsible for thread resources cleanup (stack) is not being given CPU time, causing memory leaks, unless the application thread goes into a blocked state (waiting on a synchronization primitive or delaying). This could cause the device to be stuck "blinking green" until reset.

Solution

Temporarily increase IDLE thread priority to configMAX_PRIORITIES - 1 (maximum) whenever vTaskDelete(NULL) is called using portPRE_TASK_DELETE_HOOK to clean up the stack as soon as possible and restore it back to tskIDLE_PRIORITY once IDLE thread runs using idle hook.

Steps to Test

Set a breakpoint to vApplicationIdleHook, make some thread exit, it should get executed.

Example App

N/A

References

  • [CH36038]

Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

  • [bugfix] [electron, gen3] Temporarily increase IDLE task priority whenever a thread exits (calls vTaskDelete) to resolve a memory leak that resulted in device being stuck "blinking green" until reset in some cases. #1862

@avtolstoy avtolstoy added this to the 1.3.1-rc.1 milestone Jul 23, 2019

@avtolstoy avtolstoy requested a review from technobly Jul 23, 2019

[electron, gen3] hal: temporarily increase IDLE task priority wheneve…
…r a thread exits (calls vTaskDelete(NULL))

@avtolstoy avtolstoy force-pushed the fix/freertos-idle-task-let-run branch from b18c4f8 to 2b6e565 Jul 23, 2019

hal/src/electron/rtos_hook.cpp Outdated Show resolved Hide resolved
hal/src/electron/rtos_hook.cpp Outdated Show resolved Hide resolved

@avtolstoy avtolstoy requested review from technobly and sergeuz Jul 24, 2019

@avtolstoy avtolstoy force-pushed the fix/freertos-idle-task-let-run branch from 7d82f1e to ab81144 Jul 24, 2019

@avtolstoy avtolstoy merged commit 85270f6 into develop Jul 25, 2019

3 checks passed

Codacy/PR Quality Review Up to standards. A positive pull request.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@avtolstoy avtolstoy deleted the fix/freertos-idle-task-let-run branch Jul 25, 2019

@technobly technobly removed the request for review from sergeuz Aug 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.