-
-
Notifications
You must be signed in to change notification settings - Fork 174
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
Refactor the Task
struct to reduce lock contention
#433
Merged
kevinaboos
merged 12 commits into
theseus-os:theseus_main
from
kevinaboos:refactor_task
Aug 18, 2021
Merged
Refactor the Task
struct to reduce lock contention
#433
kevinaboos
merged 12 commits into
theseus-os:theseus_main
from
kevinaboos:refactor_task
Aug 18, 2021
Conversation
This file contains 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
…n be separately accessed atomically
as it's not actually atomic. This is due to a build script configuration failure in `autocfg`, which `atomic` relies on to determine whether a given type is actually atomic on a given architecture at build time. Thus, we need to use something else, perhaps crossbeam's AtomicCell?
…micCell` because it actually compiles down the native atomic instructions! Still a WIP, things don't run properly.
github-actions bot
pushed a commit
that referenced
this pull request
Aug 18, 2021
* Move a Task's `ExitValue` out of its `RunState` so that `RunState` can be separately accessed atomically. * Move immutable fields into `Task` and mutable fields into `TaskInner` (excluding atomic fields), which reduces lock contention. Most fields can now be accessed without acquiring locks. * Use properly-aligned and -sized atomic types such that native atomic instructions are actually used. For this, we switch from `atomic::Atomic` to `crossbeam_utils::atomic::AtomicCell` since it actually compiles down to native atomics. * Statically assert that all types wrapped in `AtomicCell` actually use native atomic instructions. * The `runstate` and `running_on_cpu` fields of `Task` are now atomically accessible in a lock-free manner. This is beneficial for blocking/unblocking tasks in a lock-free context, e.g., within an interrupt handler. * Remove now-unnecessary unsafe statements from `schedule()` df721e3
github-actions bot
pushed a commit
to jacob-earle/Theseus
that referenced
this pull request
Aug 19, 2021
* Move a Task's `ExitValue` out of its `RunState` so that `RunState` can be separately accessed atomically. * Move immutable fields into `Task` and mutable fields into `TaskInner` (excluding atomic fields), which reduces lock contention. Most fields can now be accessed without acquiring locks. * Use properly-aligned and -sized atomic types such that native atomic instructions are actually used. For this, we switch from `atomic::Atomic` to `crossbeam_utils::atomic::AtomicCell` since it actually compiles down to native atomics. * Statically assert that all types wrapped in `AtomicCell` actually use native atomic instructions. * The `runstate` and `running_on_cpu` fields of `Task` are now atomically accessible in a lock-free manner. This is beneficial for blocking/unblocking tasks in a lock-free context, e.g., within an interrupt handler. * Remove now-unnecessary unsafe statements from `schedule()` df721e3
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.
Task
and mutable states intoTaskInner
atomic::Atomic
tocrossbeam_utils::atomic::AtomicCell
since it actually works. For a custom-target build like Theseus, theatomic
crate does not get configured properly (due to autocfg does not work in the presence of -Z build-std cuviper/autocfg#34) and thus doesn't actually use native atomic instructions!const_assert!()
to ensure that all types wrapped inAtomicCell
actually use native atomic instructions.runstate
andrunning_on_cpu
fields ofTask
are wrapped inAtomicCell
, enabling them to be accessed in a lock-free manner.schedule()
ExitValue
out of theRunState
enum such thatRunState
can be placed within an atomic type.