Skip to content

Implement LinuxBoard::sleep() to stop the main loop busy-spinning - #24

Merged
l5yth merged 1 commit into
linuxfrom
l5y-linux-cpu-sleep
Aug 31, 2026
Merged

Implement LinuxBoard::sleep() to stop the main loop busy-spinning#24
l5yth merged 1 commit into
linuxfrom
l5y-linux-cpu-sleep

Conversation

@l5yth

@l5yth l5yth commented Aug 31, 2026

Copy link
Copy Markdown
Owner

mesh::MainBoard::sleep() is a no-op by default and LinuxBoard never overrode it, so board.sleep(0)/sleep(30) returned immediately and the repeater loop spun a core at 100%. Only NRF52Board and ESP32Board implement it.

Implement it with sleep()/usleep(), and add a delay(1) in the main loop's non-powersaving branch so platforms without power management do not spin either.

Reported and fixed by brianhealey, measured at 99% -> 0-9% CPU on a Pi Compute Module 5 with an SX1262. Cherry-picked from #21, which could not be merged.

(cherry picked from commit 11d6ddf), closes #21

`mesh::MainBoard::sleep()` is a no-op by default and `LinuxBoard` never overrode it, so `board.sleep(0)`/`sleep(30)` returned immediately and the repeater loop spun a core at 100%. Only `NRF52Board` and `ESP32Board` implement it.

Implement it with `sleep()`/`usleep()`, and add a `delay(1)` in the main loop's non-powersaving branch so platforms without power management do not spin either.

Reported and fixed by brianhealey, measured at 99% -> 0-9% CPU on a Pi Compute Module 5 with an SX1262. Cherry-picked from #21, which could not be merged.

(cherry picked from commit 11d6ddf)
@l5yth
l5yth merged commit f114d19 into linux Aug 31, 2026
1 check passed
@l5yth
l5yth deleted the l5y-linux-cpu-sleep branch August 31, 2026 16:57
l5yth added a commit that referenced this pull request Sep 9, 2026
`mesh::MainBoard::sleep()` is a no-op by default and `LinuxBoard` never overrode it, so `board.sleep(0)`/`sleep(30)` returned immediately and the repeater loop spun a core at 100%. Only `NRF52Board` and `ESP32Board` implement it.

Implement it with `sleep()`/`usleep()`, and add a `delay(1)` in the main loop's non-powersaving branch so platforms without power management do not spin either.

Reported and fixed by brianhealey, measured at 99% -> 0-9% CPU on a Pi Compute Module 5 with an SX1262. Cherry-picked from #21, which could not be merged.

(cherry picked from commit 11d6ddf)

Co-authored-by: brianhealey <brian.healey@gmail.com>
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.

2 participants