Skip to content

Commit 203f757

Browse files
author
Eric Holk
committed
---
yaml --- r: 4219 b: refs/heads/master c: b51f5c3 h: refs/heads/master i: 4217: 82b7ae7 4215: b479448 v: v3
1 parent 34346fc commit 203f757

File tree

9 files changed

+19
-21
lines changed

9 files changed

+19
-21
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: c15871ac517136e216a1783d722307a1da1da106
2+
refs/heads/master: b51f5c395cc3458e428159b908ca95b1777e66e2

trunk/src/rt/rust.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,19 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
144144
rust_srv *srv = new rust_srv();
145145
rust_kernel *kernel = new rust_kernel(srv);
146146
kernel->start();
147-
rust_scheduler *sched = kernel->get_scheduler();
147+
rust_task *root_task = kernel->create_task(NULL, "main");
148+
rust_scheduler *sched = root_task->sched;
148149
command_line_args *args
149150
= new (kernel, "main command line args")
150-
command_line_args(sched->root_task, argc, argv);
151+
command_line_args(root_task, argc, argv);
151152

152153
DLOG(sched, dom, "startup: %d args in 0x%" PRIxPTR,
153154
args->argc, (uintptr_t)args->args);
154155
for (int i = 0; i < args->argc; i++) {
155156
DLOG(sched, dom, "startup: arg[%d] = '%s'", i, args->argv[i]);
156157
}
157158

158-
sched->root_task->start(main_fn, (uintptr_t)args->args);
159+
root_task->start(main_fn, (uintptr_t)args->args);
159160

160161
int num_threads = get_num_threads();
161162

trunk/src/rt/rust_kernel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ int rust_kernel::start_task_threads(int num_threads)
261261
return sched->rval;
262262
}
263263

264+
rust_task *
265+
rust_kernel::create_task(rust_task *spawner, const char *name) {
266+
return sched->create_task(spawner, name);
267+
}
268+
264269
#ifdef __WIN32__
265270
void
266271
rust_kernel::win32_require(LPCTSTR fn, BOOL ok) {

trunk/src/rt/rust_kernel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ class rust_kernel : public rust_thread {
121121
#ifdef __WIN32__
122122
void win32_require(LPCTSTR fn, BOOL ok);
123123
#endif
124+
125+
rust_task *create_task(rust_task *spawner, const char *name);
124126
};
125127

126128
class rust_task_thread : public rust_thread {

trunk/src/rt/rust_scheduler.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ rust_scheduler::rust_scheduler(rust_kernel *kernel,
1616
blocked_tasks(this, "blocked"),
1717
dead_tasks(this, "dead"),
1818
cache(this),
19-
root_task(NULL),
20-
curr_task(NULL),
2119
rval(0),
2220
kernel(kernel),
2321
message_queue(message_queue)
@@ -29,7 +27,6 @@ rust_scheduler::rust_scheduler(rust_kernel *kernel,
2927
pthread_attr_setstacksize(&attr, 1024 * 1024);
3028
pthread_attr_setdetachstate(&attr, true);
3129
#endif
32-
root_task = create_task(NULL, name);
3330
}
3431

3532
rust_scheduler::~rust_scheduler() {

trunk/src/rt/rust_scheduler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ struct rust_scheduler : public kernel_owned<rust_scheduler>,
4646
rust_crate_cache cache;
4747

4848
randctx rctx;
49-
rust_task *root_task;
50-
rust_task *curr_task;
5149
int rval;
5250

5351
rust_kernel *kernel;

trunk/src/rt/rust_task.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ rust_task::~rust_task()
103103

104104
/* FIXME: tighten this up, there are some more
105105
assertions that hold at task-lifecycle events. */
106-
I(sched, ref_count == 0 ||
107-
(ref_count == 1 && this == sched->root_task));
106+
// I(sched, ref_count == 0 ||
107+
// (ref_count == 1 && this == sched->root_task));
108108

109109
del_stk(this, stk);
110110
}
@@ -207,8 +207,8 @@ rust_task::kill() {
207207
// Unblock the task so it can unwind.
208208
unblock();
209209

210-
if (this == sched->root_task)
211-
sched->fail();
210+
// if (this == sched->root_task)
211+
// sched->fail();
212212

213213
LOG(this, task, "preparing to unwind task: 0x%" PRIxPTR, this);
214214
// run_on_resume(rust_unwind_glue);
@@ -229,8 +229,6 @@ rust_task::fail() {
229229
supervisor->kill();
230230
}
231231
// FIXME: implement unwinding again.
232-
if (this == sched->root_task)
233-
sched->fail();
234232
failed = true;
235233
}
236234

trunk/src/rt/rust_task.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ rust_task : public maybe_proxy<rust_task>,
123123
void die();
124124
void unblock();
125125

126-
void check_active() { I(sched, sched->curr_task == this); }
127-
void check_suspended() { I(sched, sched->curr_task != this); }
128-
129126
// Print a backtrace, if the "bt" logging option is on.
130127
void backtrace();
131128

trunk/src/rt/test/rust_test_runtime.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ void task_entry() {
4545

4646
void
4747
rust_task_test::worker::run() {
48-
rust_scheduler *scheduler = kernel->get_scheduler();
49-
scheduler->root_task->start((uintptr_t)&task_entry, (uintptr_t)NULL);
50-
scheduler->start_main_loop(0);
48+
rust_task *root_task = kernel->create_task(NULL, "main");
49+
root_task->start((uintptr_t)&task_entry, (uintptr_t)NULL);
50+
root_task->sched->start_main_loop(0);
5151
}
5252

5353
bool

0 commit comments

Comments
 (0)