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

Prevent idle priority threads from potentially starving the FreeRTOS idle task #3909

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

CookiePLMonster
Copy link
Contributor

@CookiePLMonster CookiePLMonster commented Sep 18, 2024

What's new

This PR consists of three commits:

  • FuriThreadPriorityIdle has been bumped down from 1 to 0, to be on the same priority as the FreeRTOS idle task. This allows idle priority threads to spinloop (with furi_thread_yield()) and not starve that idle task, which apps like the Direct Draw debug app or Flipper95 were previously doing. This would manifest itself by qFlipper causing future USB connections to lock up until the offending application has been closed. With this change, the idle task is given enough time to process task deletions, and prevents the lockup.
  • furi_thread_list_process was made private, because it requires a runtime parameter that can only be obtained from FreeRTOS.
  • Fixed a memory leak in the DirectDraw debug app, and made it not include canvas_i.h that wasn't needed, and made building with uFBT impossible until this include was removed.

API version bump is needed because of furi_thread_list_process, but also because of the change to the FuriThreadPriority enum.

Fixes #3908

Verification

  1. Run Direct Draw app or Flipper95.
  2. Run qFlipper, observe it shows the screen output, then close it.
  3. Attempt to run ./fbt cli. Observe that:
    • Without this PR - the command gets stuck at
      --- Miniterm on COM6  230400,8,N,1 ---
      --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
      
      until the app is closed.
    • With this PR - the command finishes successfully, showing the full prompt.

Checklist (For Reviewer)

  • PR has description of feature/bug or link to Confluence/Jira task
  • Description contains actions to verify feature/bugfix
  • I've built this code, uploaded it to the device and verified feature/bugfix

…move FuriThreadPriorityNone

This magic constant was meaningless,
FuriThreadPriorityNormal is now assigned by default instead.
Its 'runtime' parameter is to be obtained from FreeRTOS,
which means apps cannot do it.
Makes this debug app compileable with uFBT out of the box
@CookiePLMonster CookiePLMonster marked this pull request as ready for review September 20, 2024 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Idle priority threads that only yield can lock up serial USB if qFlipper is in use
1 participant