From 5db5eb0c55ff303db96390a4bf6a5365382cc357 Mon Sep 17 00:00:00 2001 From: Michael Bebenita Date: Wed, 28 Jul 2010 14:45:44 -0700 Subject: Null rust_task::cond on wakeup, add asserts and logging to block/wakeup. --- src/rt/rust_task.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/rt/rust_task.cpp') diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 6f96ac916c8..2bb0954196e 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -529,23 +529,29 @@ rust_task::transition(ptr_vec *src, ptr_vec *dst) void rust_task::block(rust_cond *on) { - I(dom, on); + log(rust_log::TASK, "Blocking on 0x%" PRIxPTR ", cond: 0x%" PRIxPTR, + (uintptr_t) on, (uintptr_t) cond); + A(dom, cond == NULL, "Cannot block an already blocked task."); + A(dom, on != NULL, "Cannot block on a NULL object."); + transition(&dom->running_tasks, &dom->blocked_tasks); - dom->log(rust_log::TASK, - "task 0x%" PRIxPTR " blocking on 0x%" PRIxPTR, - (uintptr_t)this, - (uintptr_t)on); cond = on; } void rust_task::wakeup(rust_cond *from) { + A(dom, cond != NULL, "Cannot wake up unblocked task."); + log(rust_log::TASK, "Blocked on 0x%" PRIxPTR " woken up on 0x%" PRIxPTR, + (uintptr_t) cond, (uintptr_t) from); + A(dom, cond == from, "Cannot wake up blocked task on wrong condition."); + transition(&dom->blocked_tasks, &dom->running_tasks); // TODO: Signaling every time the task is awaken is kind of silly, // do this a nicer way. dom->_progress.signal(); I(dom, cond == from); + cond = NULL; } void -- cgit 1.4.1-3-g733a5