Repository navigation
targets: sleep in the bootstrap thread instead of spinning - #627
Merged
wmaroneAMD merged 3 commits intoOct 30, 2026
Merged
Conversation
Target::main() ends in loop {} after codegen::start(). The kernel runs
target::main() on its bootstrap thread, which has DEFAULT_PRIORITY, and app
threads get DEFAULT_PRIORITY too unless the system config says otherwise. The
scheduler round-robins threads of equal priority at every tick, so a spinning
bootstrap thread takes a full time slice at each tick whenever an app thread is
runnable, and a woken thread can wait behind it. Pigweed's own reference targets
(pw_rp2350 ipc/user, clock/user) end main with
loop { kernel::sleep_until(Arch, Instant::MAX) } instead.
Apply the same to every target whose main() is just codegen::start(); loop {}:
ast10x0 (10 targets), earlgrey (4) and veer (2). Targets whose main() does other
work before looping (peripheral and kernel tests) are unchanged.
Evidence: measured on the Caliptra VeeR FPGA (a downstream fork with more veer
test targets): the 64 KiB PLDM firmware update went from 65.0 s to 49.0 s with
the FD in its own process, and from 52.2 s to 37.3 s with the FD co-located,
about 45 to 48 ms per chunk, and the scheduler tick was measured at 11.29 ms.
NOT yet built or run for this branch; CI should decide. Known risk: in the
downstream fork, with a sleeping bootstrap thread the veer
ipc_runner_emulator_test hangs at "Testing object_set_peer_user_signal"
(passes with the spinner), which looks like a latent wake-up problem the spinner
masks. Expect target/veer/ipc/user to fail until that is understood; the ARM and
earlgrey targets have not been tried.
Contributor
|
we have more than 16 occurances of the busy loop, I add 6 to this branch here: rusty1968#21 |
rusty1968
marked this pull request as ready for review
October 28, 2026 15:42
Closed
wmaroneAMD
approved these changes
Oct 30, 2026
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.
No description provided.