Skip to content

Commit a698e67

Browse files
Eric Holkgraydon
authored andcommitted
---
yaml --- r: 3359 b: refs/heads/master c: cb00bef h: refs/heads/master i: 3357: 87533b6 3355: f541e01 3351: 9bc211f 3343: 8dd8077 3327: a69d790 v: v3
1 parent 4e8f0fd commit a698e67

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 4bc773465fe95da37b8c867979786b190de6197c
2+
refs/heads/master: cb00befff050e69565d2862b458bbd56f20b7cd3

trunk/src/rt/rust.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,19 @@ command_line_args : public dom_owned<command_line_args>
7171
}
7272
};
7373

74+
int get_num_threads()
75+
{
76+
char *env = getenv("RUST_THREADS");
77+
if(env) {
78+
int num = atoi(env);
79+
if(num > 0)
80+
return num;
81+
}
82+
// TODO: in this case, determine the number of CPUs present on the
83+
// machine.
84+
return 1;
85+
}
86+
7487
/**
7588
* Main entry point into the Rust runtime. Here we create a Rust service,
7689
* initialize the kernel, create the root domain and run it.
@@ -95,7 +108,11 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
95108

96109
dom->root_task->start(main_fn, (uintptr_t)args->args);
97110

98-
int ret = dom->start_main_loops(8);
111+
int num_threads = get_num_threads();
112+
113+
DLOG(dom, dom, "Using %d worker threads.", num_threads);
114+
115+
int ret = dom->start_main_loops(num_threads);
99116
delete args;
100117
kernel->destroy_domain(dom);
101118
kernel->join_all_domains();

0 commit comments

Comments
 (0)