Skip to content

Commit 7dcac31

Browse files
committed
rt: Remove rust_task_thread::dead_tasks
1 parent 6f6650e commit 7dcac31

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

src/rt/rust_task_thread.cpp

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ rust_task_thread::rust_task_thread(rust_scheduler *sched,
2727
id(id),
2828
should_exit(false),
2929
cached_c_stack(NULL),
30+
dead_task(NULL),
3031
kernel(sched->kernel),
3132
sched(sched),
3233
srv(srv),
@@ -108,23 +109,18 @@ rust_task_thread::number_of_live_tasks() {
108109
*/
109110
void
110111
rust_task_thread::reap_dead_tasks() {
111-
if (dead_tasks.length() == 0) {
112+
if (dead_task == NULL) {
112113
return;
113114
}
114115

115-
A(this, dead_tasks.length() == 1,
116-
"Only one task should die during a single turn of the event loop");
117-
118-
// First make a copy of the dead_task list with the lock held
119-
rust_task *dead_task = dead_tasks.pop_value();
120-
121116
// Dereferencing the task will probably cause it to be released
122117
// from the scheduler, which may end up trying to take this lock
123118
lock.unlock();
124119

125120
dead_task->delete_all_stacks();
126121
// Deref the task, which may cause it to request us to release it
127122
dead_task->deref();
123+
dead_task = NULL;
128124

129125
lock.lock();
130126
}
@@ -187,14 +183,6 @@ rust_task_thread::log_state() {
187183
blocked_tasks[i]->get_cond_name());
188184
}
189185
}
190-
191-
if (!dead_tasks.is_empty()) {
192-
log(NULL, log_debug, "dead tasks:");
193-
for (size_t i = 0; i < dead_tasks.length(); i++) {
194-
log(NULL, log_debug, "\t task: %s 0x%" PRIxPTR,
195-
dead_tasks[i]->name, dead_tasks[i]);
196-
}
197-
}
198186
}
199187
/**
200188
* Starts the main scheduler loop which performs task scheduling for this
@@ -221,7 +209,7 @@ rust_task_thread::start_main_loop() {
221209
"all tasks are blocked, scheduler id %d yielding ...",
222210
id);
223211
lock.wait();
224-
A(this, dead_tasks.length() == 0,
212+
A(this, dead_task == NULL,
225213
"Tasks should only die after running");
226214
DLOG(this, task,
227215
"scheduler %d resuming ...", id);
@@ -257,7 +245,7 @@ rust_task_thread::start_main_loop() {
257245

258246
A(this, running_tasks.is_empty(), "Should have no running tasks");
259247
A(this, blocked_tasks.is_empty(), "Should have no blocked tasks");
260-
A(this, dead_tasks.is_empty(), "Should have no dead tasks");
248+
A(this, dead_task == NULL, "Should have no dead tasks");
261249

262250
DLOG(this, dom, "finished main-loop %d", id);
263251

@@ -290,8 +278,6 @@ rust_task_thread::state_list(rust_task_state state) {
290278
return &running_tasks;
291279
case task_state_blocked:
292280
return &blocked_tasks;
293-
case task_state_dead:
294-
return &dead_tasks;
295281
default:
296282
return NULL;
297283
}
@@ -332,6 +318,10 @@ rust_task_thread::transition(rust_task *task,
332318
if (dst_list) {
333319
dst_list->append(task);
334320
}
321+
if (dst == task_state_dead) {
322+
I(this, dead_task == NULL);
323+
dead_task = task;
324+
}
335325
task->set_state(dst, cond, cond_name);
336326

337327
lock.signal();

src/rt/rust_task_thread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct rust_task_thread : public kernel_owned<rust_task_thread>,
4949

5050
rust_task_list running_tasks;
5151
rust_task_list blocked_tasks;
52-
rust_task_list dead_tasks;
52+
rust_task *dead_task;
5353

5454
void prepare_c_stack(rust_task *task);
5555
void unprepare_c_stack();

0 commit comments

Comments
 (0)