Skip to content

Scheduler multithreading #6839

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

Closed
wants to merge 33 commits into from
Closed

Scheduler multithreading #6839

wants to merge 33 commits into from

Conversation

brson
Copy link
Contributor

@brson brson commented May 30, 2013

r? @nikomatsakis

This implements very basic multithreading in the new scheduler. This is only using a trivial scheduling strategy with a shared task queue. It adds three new concurrent types to the scheduler: WorkQueue, MessageQueue, and SleeperList. WorkQueue is temporarily just a basic queue; MessageQueue is a multiple-producer, singe-consumer queue for sending messages to schedulers; and SleeperList is a shared stack used for waking up sleeping schedulers. All three are intended to be lock free but for now are implemented naively with locks.

The main scheduling routine, which uses all three of these data structures is here: https://github.com/brson/rust/blob/io-upstream/src/libstd/rt/sched.rs#L156

An example of how the multithreaded scheduler is constructed: https://github.com/brson/rust/blob/io-upstream/src/libstd/rt/test.rs#L62
#4419

@nikomatsakis
Copy link
Contributor

/me reads

@nikomatsakis
Copy link
Contributor

I made a branch where I inserted comments and made some minor changes:

https://github.com/nikomatsakis/rust/tree/brson-io-upstream

This commit in particular:

nikomatsakis@6889ddb

@brson maybe we can chat with vidyo on Monday to clear up some of the things I am confused about?

@nikomatsakis
Copy link
Contributor

By the way the code is pretty nice! I'd like to see a file doc.rs with a high-level overview of the strategy. I was a bit confused about which threads could be running where at various points, and I still don't quite understand the logic behind cleanup jobs.

@brson
Copy link
Contributor Author

brson commented Jun 1, 2013

@nikomatsakis sure we can talk about it monday.

I also threw in some new commits that implement SharedChan and SharedPort. When combined they amount to an unbounded, multiple producer/multiple consumer queue.

@brson
Copy link
Contributor Author

brson commented Jun 3, 2013

Removed SharedChan/Port commits because they are buggy.

@brson
Copy link
Contributor Author

brson commented Jun 6, 2013

I've cleaned this up so it only contains the parts that I believe are pretty stable. I intend to go apply some of feedback in your commit still, but may not write the docs for a while.

@brson
Copy link
Contributor Author

brson commented Jun 6, 2013

Also, still waiting for incoming to be green. I've got that bug in my sights, though.

@nikomatsakis
Copy link
Contributor

r+. I didn't add tihs to the commit since it's not mergeable. plus, I didn't expect you to write the docs yet :)

@graydon graydon closed this Jun 13, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Mar 11, 2021
…, r=flip1995

lintcheck: fix clippy warnings

split out from rust-lang/rust-clippy#6829
changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants