From 63dcd325b909051f53682dc6ddb2d6768ffbbba3 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Wed, 29 Jun 2011 18:47:47 -0700 Subject: Adding support for pinning tasks to the currently running thread. Closes #598. --- src/rt/rust_task.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/rt/rust_task.cpp') diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 2a3342c683d..46c9aebe6cf 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -70,7 +70,8 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state, list_index(-1), rendezvous_ptr(0), handle(NULL), - active(false), + running_on(-1), + pinned_on(-1), local_region(&sched->srv->local_region), synchronized_region(&sched->srv->synchronized_region) { @@ -471,9 +472,11 @@ rust_task::get_handle() { return handle; } -bool rust_task::can_schedule() +bool rust_task::can_schedule(int id) { - return yield_timer.has_timed_out() && !active; + return yield_timer.has_timed_out() && + running_on == -1 && + (pinned_on == -1 || pinned_on == id); } void * @@ -524,6 +527,14 @@ rust_task::free(void *mem, memory_region::memory_region_type type) { return; } +void rust_task::pin() { + pinned_on = running_on; +} + +void rust_task::unpin() { + pinned_on = -1; +} + // // Local Variables: // mode: C++ -- cgit 1.4.1-3-g733a5