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

feat(threads): dynamic thread priorities #370

Merged
merged 6 commits into from
Sep 30, 2024

Conversation

elenaf9
Copy link
Collaborator

@elenaf9 elenaf9 commented Jul 31, 2024

Description

Allow users to dynamically change thread priorities at runtime.

Issues/PRs references

Fixes #320
Depends on #437

Open Questions

Change checklist

  • I have cleaned up my commit history and squashed fixup commits.
  • I have followed the Coding Conventions.
  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.

@ROMemories
Copy link
Collaborator

Seems like the hax issue in CI (lack of support for let ... else statements) is now fixed upstream.
This is not picked up because we are currently pinning hax to an earlier version:

- name: ⤵ Install and configure hax
uses: hacspec/hax-actions@main
with:
# pin hax to known-working
hax_reference: d10f891a19f96bcafa9e31b1d78763e4f3cf30b4

@elenaf9
Copy link
Collaborator Author

elenaf9 commented Aug 6, 2024

Seems like the hax issue in CI (lack of support for let ... else statements) is now fixed upstream. This is not picked up because we are currently pinning hax to an earlier version:

- name: ⤵ Install and configure hax
uses: hacspec/hax-actions@main
with:
# pin hax to known-working
hax_reference: d10f891a19f96bcafa9e31b1d78763e4f3cf30b4

Thank you for pointing this out! I opened #378 to update our hax version.

@ROMemories
Copy link
Collaborator

I see that you've already reported a few months the hax issue the CI is currently failing with.

@elenaf9 elenaf9 marked this pull request as ready for review September 13, 2024 11:04
@elenaf9
Copy link
Collaborator Author

elenaf9 commented Sep 13, 2024

Still blocked by hacspec/hax#603.

@ROMemories
Copy link
Collaborator

ROMemories commented Sep 13, 2024

Still blocked by hacspec/hax#603.

I suppose you could add a small position function helper in this module, implementing it by calling Iterator::next() manually, with a comment explaining why we don't use Iterator::position().

@elenaf9
Copy link
Collaborator Author

elenaf9 commented Sep 23, 2024

Rebased & addressed reviews. I also refactored the threads-dynamic-prios example into a test instead, because I think it's a simple API that doesn't require a separate example, but it's useful to have a test for the logic.

@elenaf9
Copy link
Collaborator Author

elenaf9 commented Sep 23, 2024

Still blocked by hacspec/hax#603.

I suppose you could add a small position function helper in this module, implementing it by calling Iterator::next() manually, with a comment explaining why we don't use Iterator::position().

I tried doing that with c969899, but unfortunately that then fails because early returns from loops aren't supported: hacspec/hax#196.
a117fc2 now implements it with a simple for-loop instead.

Edit: hmm, still doesn't work, no it fails because it doesn't know FnMut... next attempt: 33f723e.
Edit2: now fails because - Identifier not found: [v_ThreadId] even though I don't use it in any new places. Any idea why this error suddenly appear here? @ROMemories maybe?

src/riot-rs-runqueue/src/runqueue.rs Outdated Show resolved Hide resolved
src/riot-rs-threads/src/lib.rs Show resolved Hide resolved
tests/threading-dynamic-prios/Cargo.toml Outdated Show resolved Hide resolved
@elenaf9
Copy link
Collaborator Author

elenaf9 commented Sep 26, 2024

Rebased & addressed the reviews. Hax check now also passes, thanks to @ROMemories!
Per #370 (comment), get_priority and set_priority now use RunqueueIds instead of u8.
The thread_create* functions should probably also use the RunqueueId, but that's out of scope for this PR, especially because it also involves changes in our macros.

@ROMemories
Copy link
Collaborator

Could you rebase on main? I'd like to test #437 on this PR 🙂

Compared to `Runqueue::pop_head` (which previously was called
`Runqueue::del`), this also supports deleting threads that aren't head
of their rq.
@elenaf9 elenaf9 force-pushed the threads/dynamic-priorities branch 2 times, most recently from 92124c5 to 069076e Compare September 26, 2024 13:48
@ROMemories
Copy link
Collaborator

Could you rebase on main? I'd like to test #437 on this PR 🙂

Thanks! I checked the Actions logs and the lint job did error out as expected, as the previously present clippy warning is now considered an error, as expected since #437.

@kaspar030
Copy link
Collaborator

LGTM!

@elenaf9 elenaf9 added this pull request to the merge queue Sep 30, 2024
Merged via the queue into future-proof-iot:main with commit d5bfd9d Sep 30, 2024
26 checks passed
@elenaf9 elenaf9 deleted the threads/dynamic-priorities branch September 30, 2024 12:38
kaspar030 added a commit to kaspar030/RIOT-rs that referenced this pull request Oct 1, 2024
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.

feat: provide API to change thread priority
3 participants