Skip to content

Commit 563d6b6

Browse files
committed
---
yaml --- r: 21815 b: refs/heads/snap-stage3 c: 6f9539a h: refs/heads/master i: 21813: 08b5ae1 21811: 5f17596 21807: 5433231 v: v3
1 parent 6606343 commit 563d6b6

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: e430a699f2c60890d9b86069fd0c68a70ece7120
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: b776395263bfc9908d8fec80d7d1d0f67b8490e8
4+
refs/heads/snap-stage3: 6f9539a15c4f09dfa296d5f815ca341af1345382
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/task.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,11 +1403,9 @@ fn spawn_raw(+opts: TaskOpts, +f: fn~()) {
14031403

14041404
let num_threads = match opts.mode {
14051405
SingleThreaded => 1u,
1406-
ThreadPerCore => {
1407-
fail ~"thread_per_core scheduling mode unimplemented"
1408-
}
1406+
ThreadPerCore => rustrt::rust_num_threads(),
14091407
ThreadPerTask => {
1410-
fail ~"thread_per_task scheduling mode unimplemented"
1408+
fail ~"ThreadPerTask scheduling mode unimplemented"
14111409
}
14121410
ManualThreads(threads) => {
14131411
if threads == 0u {
@@ -1657,6 +1655,8 @@ extern mod rustrt {
16571655

16581656
fn rust_get_sched_id() -> sched_id;
16591657
fn rust_new_sched(num_threads: libc::uintptr_t) -> sched_id;
1658+
fn sched_threads() -> libc::size_t;
1659+
fn rust_num_threads() -> libc::uintptr_t;
16601660

16611661
fn get_task_id() -> task_id;
16621662
#[rust_stack]
@@ -2422,3 +2422,13 @@ fn test_tls_cleanup_on_failure() unsafe {
24222422
local_data_set(int_key, @31337);
24232423
fail;
24242424
}
2425+
2426+
#[test]
2427+
fn test_sched_thread_per_core() {
2428+
let cores = rustrt::rust_num_threads();
2429+
let mut reported_threads = 0u;
2430+
do spawn_sched(ThreadPerCore) {
2431+
reported_threads = rustrt::sched_threads();
2432+
}
2433+
assert(cores == reported_threads);
2434+
}

branches/snap-stage3/src/rt/rust_builtin.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,12 @@ rust_get_sched_id() {
572572
return task->sched->get_id();
573573
}
574574

575+
extern "C" CDECL uintptr_t
576+
rust_num_threads() {
577+
rust_task *task = rust_get_current_task();
578+
return task->kernel->env->num_sched_threads;
579+
}
580+
575581
extern "C" CDECL rust_sched_id
576582
rust_new_sched(uintptr_t threads) {
577583
rust_task *task = rust_get_current_task();
@@ -620,7 +626,7 @@ start_task(rust_task *target, fn_env_pair *f) {
620626
target->start(f->f, f->env, NULL);
621627
}
622628

623-
extern "C" CDECL int
629+
extern "C" CDECL size_t
624630
sched_threads() {
625631
rust_task *task = rust_get_current_task();
626632
return task->sched->number_of_threads();

branches/snap-stage3/src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ rand_seed
3232
rust_get_sched_id
3333
rust_new_sched
3434
rust_new_task_in_sched
35+
rust_num_threads
3536
rust_path_is_dir
3637
rust_path_exists
3738
rust_getcwd

0 commit comments

Comments
 (0)