Skip to content

Commit 0581c60

Browse files
committed
---
yaml --- r: 14643 b: refs/heads/try c: b2a075e h: refs/heads/master i: 14641: 86e599a 14639: 31c4c2b v: v3
1 parent 1015d2b commit 0581c60

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: d7298a797b1041e9e997378bdb3cd4923567b2d4
5+
refs/heads/try: b2a075e20d07994c960a7598fee2771d10cb9989
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rt/rust_task.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
7474
cache(NULL),
7575
kernel(thread->kernel),
7676
name(name),
77-
state(state),
7877
cond(NULL),
7978
cond_name("none"),
8079
list_index(-1),
@@ -87,6 +86,7 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
8786
dynastack(this),
8887
cc_counter(0),
8988
total_stack_sz(0),
89+
state(state),
9090
killed(false),
9191
reentered_rust_stack(false),
9292
c_stack(NULL),
@@ -355,12 +355,14 @@ rust_task::get_frame_glue_fns(uintptr_t fp) {
355355
bool
356356
rust_task::running()
357357
{
358+
scoped_lock with(state_lock);
358359
return state == &thread->running_tasks;
359360
}
360361

361362
bool
362363
rust_task::blocked()
363364
{
365+
scoped_lock with(state_lock);
364366
return state == &thread->blocked_tasks;
365367
}
366368

@@ -373,6 +375,7 @@ rust_task::blocked_on(rust_cond *on)
373375
bool
374376
rust_task::dead()
375377
{
378+
scoped_lock with(state_lock);
376379
return state == &thread->dead_tasks;
377380
}
378381

@@ -407,7 +410,10 @@ rust_task::transition(rust_task_list *src, rust_task_list *dst) {
407410
I(thread, state == src);
408411
src->remove(this);
409412
dst->append(this);
410-
state = dst;
413+
{
414+
scoped_lock with(state_lock);
415+
state = dst;
416+
}
411417
thread->lock.signal();
412418
if(unlock)
413419
thread->lock.unlock();

branches/try/src/rt/rust_task.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ rust_task : public kernel_owned<rust_task>, rust_cond
6868
// Fields known only to the runtime.
6969
rust_kernel *kernel;
7070
const char *const name;
71-
rust_task_list *state;
7271
rust_cond *cond;
7372
const char *cond_name;
7473
int32_t list_index;
@@ -107,6 +106,9 @@ rust_task : public kernel_owned<rust_task>, rust_cond
107106

108107
private:
109108

109+
lock_and_signal state_lock;
110+
rust_task_list *state;
111+
110112
// Protects the killed flag
111113
lock_and_signal kill_lock;
112114
// Indicates that the task was killed and needs to unwind
@@ -218,6 +220,8 @@ rust_task : public kernel_owned<rust_task>, rust_cond
218220
bool have_c_stack() { return c_stack != NULL; }
219221

220222
rust_port_selector *get_port_selector() { return &port_selector; }
223+
224+
rust_task_list *get_state() { return state; }
221225
};
222226

223227
// This stuff is on the stack-switching fast path

branches/try/src/rt/rust_task_thread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ rust_task_thread::start_main_loop() {
259259
", state: %s",
260260
scheduled_task->name,
261261
(uintptr_t)scheduled_task,
262-
scheduled_task->state->name);
262+
scheduled_task->get_state()->name);
263263

264264
place_task_in_tls(scheduled_task);
265265

@@ -273,7 +273,7 @@ rust_task_thread::start_main_loop() {
273273
" in state '%s', worker id=%d" PRIxPTR,
274274
scheduled_task->name,
275275
(uintptr_t)scheduled_task,
276-
scheduled_task->state->name,
276+
scheduled_task->get_state()->name,
277277
id);
278278

279279
reap_dead_tasks();

0 commit comments

Comments
 (0)