Skip to content

targets: sleep in the bootstrap thread instead of spinning - #627

Merged
wmaroneAMD merged 3 commits into
OpenPRoT:mainfrom
rusty1968:targets-sleep-bootstrap-thread
Oct 30, 2026
Merged

wmaroneAMD merged 3 commits into
OpenPRoT:mainfrom
rusty1968:targets-sleep-bootstrap-thread

Conversation

@rusty1968

Copy link
Copy Markdown
Collaborator

No description provided.

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.
@JesseMelon

Copy link
Copy Markdown
Contributor

we have more than 16 occurances of the busy loop, I add 6 to this branch here: rusty1968#21

@rusty1968
rusty1968 marked this pull request as ready for review October 28, 2026 15:42
@EnmanuelParache EnmanuelParache mentioned this pull request Oct 30, 2026
@wmaroneAMD
wmaroneAMD merged commit 0e55397 into OpenPRoT:main Oct 30, 2026
5 checks passed
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.

3 participants