about summary refs log tree commit diff
path: root/library/std/src/sys/unix/thread.rs
AgeCommit message (Collapse)AuthorLines
2021-10-06Rollup merge of #89324 - yoshuawuyts:hardware-parallelism, r=m-ou-seManish Goregaokar-1/+1
Rename `std::thread::available_conccurrency` to `std::thread::available_parallelism` _Tracking issue: https://github.com/rust-lang/rust/issues/74479_ This PR renames `std::thread::available_conccurrency` to `std::thread::available_parallelism`. ## Rationale The API was initially named `std::thread::hardware_concurrency`, mirroring the [C++ API of the same name](https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency). We eventually decided to omit any reference to the word "hardware" after [this comment](https://github.com/rust-lang/rust/pull/74480#issuecomment-662045841). And so we ended up with `available_concurrency` instead. --- For a talk I was preparing this week I was reading through ["Understanding and expressing scalable concurrency" (A. Turon, 2013)](http://aturon.github.io/academic/turon-thesis.pdf), and the following passage stood out to me (emphasis mine): > __Concurrency is a system-structuring mechanism.__ An interactive system that deals with disparate asynchronous events is naturally structured by division into concurrent threads with disparate responsibilities. Doing so creates a better fit between problem and solution, and can also decrease the average latency of the system by preventing long-running computations from obstructing quicker ones. > __Parallelism is a resource.__ A given machine provides a certain capacity for parallelism, i.e., a bound on the number of computations it can perform simultaneously. The goal is to maximize throughput by intelligently using this resource. For interactive systems, parallelism can decrease latency as well. _Chapter 2.1: Concurrency is not Parallelism. Page 30._ --- _"Concurrency is a system-structuring mechanism. Parallelism is a resource."_ — It feels like this accurately captures the way we should be thinking about these APIs. What this API returns is not "the amount of concurrency available to the program" which is a property of the program, and thus even with just a single thread is effectively unbounded. But instead it returns "the amount of _parallelism_ available to the program", which is a resource hard-constrained by the machine's capacity (and can be further restricted by e.g. operating systems). That's why I'd like to propose we rename this API from `available_concurrency` to `available_parallelism`. This still meets the criteria we previously established of not attempting to define what exactly we mean by "hardware", "threads", and other such words. Instead we only talk about "concurrency" as an abstract resource available to our program. r? `@joshtriplett`
2021-10-06Add new target armv7-unknown-linux-uclibceabihfYannick Koehler-1/+2
Co-authored-by: Jonah Petri <jonah@petri.us>
2021-10-02haiku thread affinity build fixDavid Carlier-6/+10
2021-09-28Rename `std::thread::available_onccurrency` to ↵Yoshua Wuyts-1/+1
`std::thread::available_parallelism`
2021-09-27thread: implements available_concurrency on haikuDavid Carlier-1/+10
2021-08-10STD support for the ESP-IDF frameworkivmarkov-17/+46
2021-07-28thread set_name haiku implementation.David Carlier-2/+9
2021-07-24Auto merge of #84589 - In-line:zircon-thread-name, r=JohnTitorbors-4/+30
Implement setting thread name for Fuchsia
2021-07-10Change `weak!` and `linkat!` to macros 2.0Aris Merchant-0/+2
`weak!` is needed in a test in another module. With macros 1.0, importing `weak!` would require reordering module declarations in `std/src/lib.rs`, which is a bit too evil.
2021-06-21Use `Unsupported` on platforms where `available_concurrency` is not implemented.Christiaan Dirkx-1/+1
2021-06-21Move `available_concurrency` implementation to `sys`Christiaan Dirkx-0/+83
2021-04-27Update library/std/src/sys/unix/thread.rsAlik Aslanyan-1/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-04-26Implement setting thread name for FuchsiaAlik Aslanyan-4/+30
2021-04-01Fix stack overflow detection on FreeBSD 11.1+Alan Somers-7/+16
Beginning with FreeBSD 10.4 and 11.1, there is one guard page by default. And the stack autoresizes, so if Rust allocates its own guard page, then FreeBSD's will simply move up one page. The best solution is to just use the OS's guard page.
2021-03-17Display error details when a `mmap` call failsYuki Okushi-2/+3
2021-02-27Remove the x86_64-rumprun-netbsd targetSimonas Kazlauskas-2/+2
Closes #81514
2020-11-12Auto merge of #78965 - jryans:emscripten-threads-libc, r=kennytmbors-19/+1
Update thread and futex APIs to work with Emscripten This updates the thread and futex APIs in `std` to match the APIs exposed by Emscripten. This allows threads to run on `wasm32-unknown-emscripten` and the thread parker to compile without errors related to the missing `futex` module. To make use of this, Rust code must be compiled with `-C target-feature=atomics` and Emscripten must link with `-pthread`. I have confirmed this works well locally when building multithreaded crates. Attempting to enable `std` thread tests currently fails for seemingly obscure reasons and Emscripten is currently disabled in CI, so further work is needed to have proper test coverage here.
2020-11-12Update thread and futex APIs to work with EmscriptenJ. Ryan Stinnett-19/+1
This updates the thread and futex APIs in `std` to match the APIs exposed by Emscripten. This allows threads to run on `wasm32-unknown-emscripten` and the thread parker to compile without errors related to the missing `futex` module. To make use of this, Rust code must be compiled with `-C target-feature=atomics` and Emscripten must link with `-pthread`. I have confirmed this works well locally when building multithreaded crates. Attempting to enable `std` thread tests currently fails for seemingly obscure reasons and Emscripten is currently disabled in CI, so further work is needed to have proper test coverage here.
2020-10-31fix aliasing issue in unix sleep functionRalf Jung-1/+2
2020-10-16Take sys/vxworks/thread from sys/unix instead.Mara Bos-3/+6
2020-09-09Only call pthread_attr_destroy() after getattr_np() succeeds on all libcsTavian Barnes-2/+4
The calling convention of pthread_getattr_np() is to initialize the pthread_attr_t, so _destroy() is only necessary on success (and _init() isn't necessary beforehand). On the other hand, FreeBSD wants the attr_t to be initialized before pthread_attr_get_np(), and therefore it should always be destroyed afterwards.
2020-09-09Fix segfault if pthread_getattr_np failsTavian Barnes-2/+6
glibc destroys[1] the passed pthread_attr_t if pthread_getattr_np() fails. Destroying it again leads to a segfault. Fix it by only destroying it on success for glibc. [1]: https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_getattr_np.c;h=ce437205e41dc05653e435f6188768cccdd91c99;hb=HEAD#l205
2020-08-19Enable stack-overflow detection on musl for non-main threadsTomasz Miąsko-6/+21
2020-07-27mv std libs to library/mark-0/+465