-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
std::thread
support for the Nintendo 3DS
#98514
base: master
Are you sure you want to change the base?
Conversation
Priority and affinity are passed through special pthread attr functions which will be added to our libc fork. The current thread's priority also needs to be fetched since it is the default priority value. This is done using another new pthread function, though this value/mechanism isn't exposed as part of std's API.
…zon::thread Also renamed "affinity" to "processor_id".
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
//! | ||
//! [`std::thread`]: crate::thread | ||
|
||
#![unstable(feature = "horizon_thread_ext", issue = "none")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at creating a tracking issue for this, but held off for now due to this note in the template:
If the new feature is small, it may be fine to skip the RFC process. In that
case, you can use useissue = "none"
in your initial implementation PR. The
reviewer will ask you to open a tracking issue if they agree your feature can be
added without an RFC.
So once someone comments that this is an acceptable feature to skip an RFC for, I can create the tracking issue.
@rustbot label +T-libs-api Since this adds an unstable library feature. |
r? @nagisa You reviewed the std PR and were very helpful, so hopefully you can help review this PR as well :). |
r? @rust-lang/libs This seems reasonable enough to me, but I’m not in a position to vet changes to a stable and widely used type like the thread builder. |
Per the latest guidance from T-libs-api, I believe you'll want to file an MCP on their repo (see the opening comment from rust-highfive):
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
I've opened the ACP: rust-lang/libs-team#71 |
Registering as a quick comment that I'd prefer to see this not go in in its current form, and instead be changed in one of two ways. Will comment further on the ACP. |
☔ The latest upstream changes (presumably #103513) made this pull request unmergeable. Please resolve the merge conflicts. |
It seems this is blocked on #195 |
Rustc supports compiling for the Nintendo 3DS using the
armv6k-nintendo-3ds
target (Tier 3). Just recently we merged std support in #95897. A notable exclusion wasstd::thread
support, which was moved into this PR as a follow-up since it required more complicated changes.See #95897 for background on how rustc is able to support std for the 3DS.
A notable change in this PR is the addition of a "native options" parameter to the internal implementation of the thread builder on each platform. This is due to the 3DS requiring the "processor ID" where the thread should be spawned (certain cores are either cooperative or preemptive) and the thread priority up-front. There is an unstable thread builder extension trait added which allows users to set these values.
There are 2 non-portable pthread APIs which we depend on. Where possible, we tried to reuse existing standard APIs, but there are some features of the 3DS thread system which required us to add non-portable functions.
pthread_attr_setprocessorid_np
: Used to set the new thread's processor ID.pthread_getprocessorid_np
: Used to retrieve the current thread's processor ID.These are both implemented by https://github.com/Meziu/pthread-3ds, which is already noted as in the platform support doc as a requirement for the target's std support (note: it provides the backend for other pthread-based types such as
Mutex
). These functions have already been added tolibc
and are in the currently used version (rust-lang/libc#2715).Edit: libs team ACP has been opened for the changes to the thread builder: rust-lang/libs-team#71Blocked on #101222and ACPrust-lang/libs-team#71rust-lang/libs-team#195