core: Allocate threads on demand, not on scheduler startup

API change: rust_kernel::create_scheduler() or
rust_scheduler::rust_scheduler() respecitevly now take ownership of the
launch factory argument, it is needed to create new threads on demand.

Also renames rustrt::sched_threads() to rustrt::rust_sched_threads() for
consistency. Added rustrt::rust_max_sched_threads() to return the
maximal number of scheduled threads of the current scheduler.

Fixes #3493.
This commit is contained in:
Philipp Brüschweiler
2012-09-14 15:01:17 +02:00
committed by Brian Anderson
parent 35a9353774
commit 68e755b1c2
8 changed files with 102 additions and 48 deletions

View File

@@ -26,7 +26,7 @@ export run_tests_console;
#[abi = "cdecl"]
extern mod rustrt {
fn sched_threads() -> libc::size_t;
fn rust_max_sched_threads() -> libc::size_t;
}
// The name of a test. By convention this follows the rules for rust
@@ -327,7 +327,7 @@ const sched_overcommit : uint = 1u;
const sched_overcommit : uint = 4u;
fn get_concurrency() -> uint {
let threads = rustrt::sched_threads() as uint;
let threads = rustrt::rust_max_sched_threads() as uint;
if threads == 1u { 1u }
else { threads * sched_overcommit }
}