mozilla/rust — pull request #1781 by brson (2012-02-08 07:02:17+00:00)
Title: Add support for multiple schedulers

This series adds support to the kernel for dynamically adding and removing schedulers then adds a single user-visible function, task::spawn_sched for spawning a task into a new scheduler. I have not implemented the full design for first-class schedulers, and think I may let this sit as-is for awhile while we review what we want the core::task API to look like (it's quite a mess these days).

For the most part this not that interesting, but commits bde9385dc5f207629381d61db7349f92035c40b9, 0f4ca21e9cd26b6b7d8c6d3bfdf07e949aaa985c, and 36d51818838a45906c8471569b60002d39ea28ff make big changes to the scheduler and task lifecycle and synchronization protocols to eliminate races between scheduler and task destruction and allow schedulers to be destroyed while the kernel is running. It's a little mind-bending, with a lot of events happening on various threads, and I probably can't explain how the kernel/scheduler/task_thread/tasks cooperate to shutdown the kernel without tracing through the code, but I left lots of comments.

This change also breaks `rust_kernel::fail` (the function the kills all tasks) even worse than before. It's very racy, but doesn't break any existing tests.

I'm doing some stress tests now to make sure things are still reliable.