Repository navigation
Run app_main at osPriorityRealtime so Module threads start after initialization - #9
Merged
Merged
Conversation
…ialization app_main runs in the default task at osPriorityNormal (24). With configMAX_PRIORITIES 56 the LibXR levels are MEDIUM 22, HIGH 33 and REALTIME 44, so a HIGH or REALTIME thread created by a Module constructor preempted app_main before the remaining Modules were constructed. The other FreeRTOS BSPs call app_main() before the scheduler starts. The default task now runs at osPriorityRealtime (48); app_main sleeps once initialization is done.
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR raises the FreeRTOS default task to osPriorityRealtime, above the LibXR thread priorities, preventing Module-created HIGH or REALTIME threads from preempting app_main during sequential initialization; the generated project metadata was updated accordingly. Sequence diagram for prioritized app initializationsequenceDiagram
participant Scheduler
participant defaultTask
participant ModuleThreads
Scheduler->>defaultTask: app_main()
Note over defaultTask: osPriorityRealtime 48
defaultTask->>ModuleThreads: Construct Modules and create threads
Note over ModuleThreads: LibXR HIGH 33 and REALTIME 44
ModuleThreads-->>defaultTask: Initialization continues
defaultTask->>defaultTask: Thread::Sleep(UINT32_MAX)
Note over defaultTask: Sleeps after initialization
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
app_main runs in the default task at
osPriorityNormal(24). WithconfigMAX_PRIORITIES56 the LibXR priorities are MEDIUM 22, HIGH 33 and REALTIME 44, so a HIGH or REALTIME thread created in a Module constructor preempts app_main while later Modules are not constructed yet. DevC, F103 and OpenCR call app_main() in main() before the scheduler starts, so their initialization is never preempted.The default task now runs at
osPriorityRealtime(48), above every LibXR level; app_main ends inXRobotMain(), which loops onThread::Sleep(1000), so after initialization the task wakes only once a second and sleeps again.Check: CubeMX regenerated the project from the edited .ioc; the only source change is the priority in
Core/Src/freertos.c. Not run on hardware yet; to be verified on an MC02 board before merging.Summary by Sourcery
Ensure application startup completes before LibXR threads can preempt module initialization.
Bug Fixes:
Enhancements:
Chores: