Make linked task failure work again

This commit is contained in:
Brian Anderson 2011-09-14 14:20:13 -07:00
parent c61f06fde9
commit 9505d70513
3 changed files with 14 additions and 4 deletions

View File

@ -74,6 +74,7 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state,
local_region(&sched->srv->local_region),
_on_wakeup(NULL),
failed(false),
killed(false),
propagate_failure(true),
dynastack(this)
{
@ -253,10 +254,19 @@ rust_task::yield(size_t time_in_us) {
LOG(this, task, "task %s @0x%" PRIxPTR " yielding for %d us",
name, this, time_in_us);
if (killed) {
killed = false;
fail();
}
yield_timer.reset_us(time_in_us);
// Return to the scheduler.
ctx.next->swap(ctx);
if (killed) {
killed = false;
fail();
}
}
void
@ -270,12 +280,11 @@ rust_task::kill() {
// from task A and want to force-fail task B, you do B->kill().
// If you want to fail yourself you do self->fail().
LOG(this, task, "killing task %s @0x%" PRIxPTR, name, this);
// When the task next goes to yield or resume it will fail
killed = true;
// Unblock the task so it can unwind.
unblock();
if (NULL == supervisor && propagate_failure)
sched->fail();
sched->lock.signal();
LOG(this, task, "preparing to unwind task: 0x%" PRIxPTR, this);

View File

@ -102,6 +102,8 @@ rust_task : public kernel_owned<rust_task>, rust_cond
// Indicates that the task ended in failure
bool failed;
// Indicates that the task was killed and needs to unwind
bool killed;
bool propagate_failure;
lock_and_signal lock;

View File

@ -1,7 +1,6 @@
// -*- rust -*-
// error-pattern:1 == 2
// xfail-test
use std;
import std::task;
import std::comm::port;