File tree Expand file tree Collapse file tree 4 files changed +23
-6
lines changed Expand file tree Collapse file tree 4 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9
- refs/heads/incoming: b776395263bfc9908d8fec80d7d1d0f67b8490e8
9
+ refs/heads/incoming: 6f9539a15c4f09dfa296d5f815ca341af1345382
10
10
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
11
11
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
12
12
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Original file line number Diff line number Diff line change @@ -1403,11 +1403,9 @@ fn spawn_raw(+opts: TaskOpts, +f: fn~()) {
1403
1403
1404
1404
let num_threads = match opts. mode {
1405
1405
SingleThreaded => 1 u,
1406
- ThreadPerCore => {
1407
- fail ~"thread_per_core scheduling mode unimplemented"
1408
- }
1406
+ ThreadPerCore => rustrt:: rust_num_threads( ) ,
1409
1407
ThreadPerTask => {
1410
- fail ~"thread_per_task scheduling mode unimplemented"
1408
+ fail ~"ThreadPerTask scheduling mode unimplemented"
1411
1409
}
1412
1410
ManualThreads ( threads) => {
1413
1411
if threads == 0 u {
@@ -1657,6 +1655,8 @@ extern mod rustrt {
1657
1655
1658
1656
fn rust_get_sched_id( ) -> sched_id;
1659
1657
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;
1660
1660
1661
1661
fn get_task_id( ) -> task_id;
1662
1662
#[ rust_stack]
@@ -2422,3 +2422,13 @@ fn test_tls_cleanup_on_failure() unsafe {
2422
2422
local_data_set( int_key, @31337 ) ;
2423
2423
fail;
2424
2424
}
2425
+
2426
+ #[ test]
2427
+ fn test_sched_thread_per_core( ) {
2428
+ let cores = rustrt:: rust_num_threads( ) ;
2429
+ let mut reported_threads = 0 u;
2430
+ do spawn_sched( ThreadPerCore ) {
2431
+ reported_threads = rustrt:: sched_threads( ) ;
2432
+ }
2433
+ assert( cores == reported_threads) ;
2434
+ }
Original file line number Diff line number Diff line change @@ -572,6 +572,12 @@ rust_get_sched_id() {
572
572
return task->sched ->get_id ();
573
573
}
574
574
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
+
575
581
extern " C" CDECL rust_sched_id
576
582
rust_new_sched (uintptr_t threads) {
577
583
rust_task *task = rust_get_current_task ();
@@ -620,7 +626,7 @@ start_task(rust_task *target, fn_env_pair *f) {
620
626
target->start (f->f , f->env , NULL );
621
627
}
622
628
623
- extern " C" CDECL int
629
+ extern " C" CDECL size_t
624
630
sched_threads () {
625
631
rust_task *task = rust_get_current_task ();
626
632
return task->sched ->number_of_threads ();
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ rand_seed
32
32
rust_get_sched_id
33
33
rust_new_sched
34
34
rust_new_task_in_sched
35
+ rust_num_threads
35
36
rust_path_is_dir
36
37
rust_path_exists
37
38
rust_getcwd
You can’t perform that action at this time.
0 commit comments