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

Add rt-aware blocking semaphores in sys.rs, for use in exclusive ARCs #2795

Closed
bblum opened this issue Jul 3, 2012 · 4 comments
Closed

Add rt-aware blocking semaphores in sys.rs, for use in exclusive ARCs #2795

bblum opened this issue Jul 3, 2012 · 4 comments
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-enhancement Category: An issue proposing an enhancement or a PR with one. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot.

Comments

@bblum
Copy link
Contributor

bblum commented Jul 3, 2012

Exclusive ARCs currently use pthread mutexes directly (through lock_and_signal). Blocking on one of these will take the entire sched_loop offline until the mutex can be grabbed.

However, the runtime scheduler knows when a thread blocks on a lock_and_signal's associated condition variable, and can schedule other useful work.

If we built a semaphore on top of lock_and_signal + condition, then the semaphore could be used for mutual exclusion in a way that would let the scheduler do other useful work while a thread is blocked on one. Then it would be less bad to do an O(n) operation inside of an exclusive.

The downside is that no longer would the exclusive be able to pass through a condition variable, such as is needed in newcomm.rs. newcomm.rs is going away, but might something else need it?

@ghost ghost assigned bblum Jul 3, 2012
@bblum
Copy link
Contributor Author

bblum commented Jul 3, 2012

also not sure how safe the cvar blocking path is. it'd need to be bulletproof if we're going to rely on it for linked failure

@bblum
Copy link
Contributor Author

bblum commented Jul 6, 2012

Also they'd undoubtedly be slower, involving system calls in any contention path. Maybe having explicit runtime support would be better, if not too hard.

@eholk
Copy link
Contributor

eholk commented Jul 6, 2012

For what it's worth, I got rid of newcomm.rs today, so you don't need to keep its needs in mind while designing this.

See 604f7c6

@bblum
Copy link
Contributor Author

bblum commented Aug 13, 2012

This is done, on the way to completing #3145.

@bblum bblum closed this as completed Aug 13, 2012
@bblum bblum removed their assignment Jun 16, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 7, 2022
…-obk

Fix invalid special casing of the unreachable! macro

This pull-request fix an invalid special casing of the `unreachable!` macro in the same way the `panic!` macro was solved, by adding two new internal only macros `unreachable_2015` and `unreachable_2021` edition dependent and turn `unreachable!` into a built-in macro that do dispatching. This logic is stolen from the `panic!` macro.

~~This pull-request also adds an internal feature `format_args_capture_non_literal` that allows capturing arguments from formatted string that expanded from macros. The original RFC rust-lang#2795 mentioned this as a future possibility. This feature is [required](rust-lang#92137 (comment)) because of concatenation that needs to be done inside the macro:~~
```rust
$crate::concat!("internal error: entered unreachable code: ", $fmt)
```

**In summary** the new behavior for the `unreachable!` macro with this pr is:

Edition 2021:
```rust
let x = 5;
unreachable!("x is {x}");
```
```
internal error: entered unreachable code: x is 5
```

Edition <= 2018:
```rust
let x = 5;
unreachable!("x is {x}");
```
```
internal error: entered unreachable code: x is {x}
```

Also note that the change in this PR are **insta-stable** and **breaking changes** but this a considered as being a [bug](rust-lang#92137 (comment)).
If someone could start a perf run and then a crater run this would be appreciated.

Fixes rust-lang#92137
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-enhancement Category: An issue proposing an enhancement or a PR with one. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot.
Projects
None yet
Development

No branches or pull requests

2 participants