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

Implement scheduler domains #1721

Closed
brson opened this issue Jan 31, 2012 · 4 comments
Closed

Implement scheduler domains #1721

brson opened this issue Jan 31, 2012 · 4 comments
Assignees
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows

Comments

@brson
Copy link
Contributor

brson commented Jan 31, 2012

Lots of bindings want to be able to block in C code. The easiest way to make this happen is to reintroduce 'thread domains'. I suggested one way in #10.

@ghost ghost assigned brson Jan 31, 2012
@graydon
Copy link
Contributor

graydon commented Jan 31, 2012

I like the look of it. The design I was thinking uses slightly different terminology and interface, but essentially the same idea:

  • scheduler is a container for threads and tasks. domain is a less-familiar term, and thread or task_thread is fine for a thread that runs tasks.
  • A scheduler is first-class. Users can make new ones and inject tasks into them. spawn(f) effectively does task::get_current_scheduler().add_task(task::create(f))
  • A thread is not first-class, as their lifecycle tends to be extremely platform-specific and it's not generally safe to start or kill one any old time you like. Users can, however, set policy about how many threads are active in a given scheduler. Three policies exist:
    • THREAD_PER_CORE makes 1 thread per core and maps tasks to threads M:N
    • THREAD_PER_TASK makes 1 thread per task.
    • MANUAL_THREADS makes exactly as many threads as a user asks for.
  • By default there is one THREAD_PER_CORE scheduler.
  • Every C call takes the thread "out of service" from running tasks; we will not switch-away from the calling task (even if we re-enter the runtime, or some task code, from a C callback) until the outermost C call completes. This means in a THREAD_PER_CORE scheduler, you should not call code that's going to block in C, if you want to avoid starving the scheduler of threads. Make a secondary scheduler in MANUAL_THREADS mode and put your blocking tasks in there.

@brson
Copy link
Contributor Author

brson commented Feb 3, 2012

Implementing your design.

@brson
Copy link
Contributor Author

brson commented Feb 4, 2012

I've refactored rust_scheduler into rust_scheduler + rust_task_thread.

@brson
Copy link
Contributor Author

brson commented Feb 9, 2012

Implemented enough to satisfy current use cases. Declaring victory. Opened #1788.

@brson brson closed this as completed Feb 9, 2012
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 24, 2020
New lint: result-unit-err

This fixes rust-lang#1721.

- [x] Followed [lint naming conventions][lint_naming]
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `cargo dev update_lints`
- [x] Added lint documentation
- [x] Run `cargo dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

---

changelog: new lint: result-unit-err
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
Projects
None yet
Development

No branches or pull requests

2 participants