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

riot-rs-threads: cortex_m: make sched() less hacky #187

Merged
merged 1 commit into from
May 2, 2024

Conversation

kaspar030
Copy link
Collaborator

This moves the previusly manual critical section into sched(), and uses a "u128" to pass our values to the assembly.
(this adds an instruction or two, but on nrf52840dk, this is barely measurable).

@kaspar030 kaspar030 requested a review from elenaf9 March 15, 2024 10:08
@kaspar030
Copy link
Collaborator Author

(marked as draft as this needs testing)

src/riot-rs-threads/src/arch/cortex_m.rs Outdated Show resolved Hide resolved
src/riot-rs-threads/src/arch/cortex_m.rs Outdated Show resolved Hide resolved
src/riot-rs-threads/src/arch/cortex_m.rs Outdated Show resolved Hide resolved
src/riot-rs-threads/src/arch/cortex_m.rs Outdated Show resolved Hide resolved
@elenaf9
Copy link
Collaborator

elenaf9 commented May 2, 2024

Friendly ping @kaspar030.

Is anything blocking this PR? I am currently working on an alternative implementation of #241, where these changes are relevant.

Happy to take over the PR and do the rebasing/ solving of merge conflicts.

@kaspar030
Copy link
Collaborator Author

Is anything blocking this PR? I am currently working on an alternative implementation of #241, where these changes are relevant.

I've rebased the PR and updated it to support the current_thread==None case. IMO it's good to go.
I did a quick benchmark, on nrf52840dk this uses some cycles less (230 -> 227). With only one thread, some cycles more (80 -> 86). I'd be fine with those numbers as we'll be touching / optimizing this anyways.

@kaspar030 kaspar030 marked this pull request as ready for review May 2, 2024 13:12
Copy link
Collaborator

@elenaf9 elenaf9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@kaspar030 kaspar030 added this pull request to the merge queue May 2, 2024
Merged via the queue into future-proof-iot:main with commit c88d075 May 2, 2024
16 checks passed
@kaspar030 kaspar030 deleted the improve_cortex_m_sched branch May 2, 2024 15:42
elenaf9 added a commit to elenaf9/RIOT-rs that referenced this pull request May 3, 2024
Refactor `arch::cortex_m::sched`, based on
future-proof-iot#187.
The previous implementation didn't use `CriticalSection` correctly,
which allowed two threads on different cores to enter `sched` at the same
time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants