aboutsummaryrefslogtreecommitdiff
path: root/src/rt/rust_dom.cpp
diff options
context:
space:
mode:
authorMichael Bebenita <[email protected]>2010-08-11 21:23:34 -0700
committerMichael Bebenita <[email protected]>2010-08-11 21:24:04 -0700
commit988695a96cee1eb825435260a1874b8daa0e590a (patch)
treeee92e117a653c8c6fad100e7416afe5468073ff3 /src/rt/rust_dom.cpp
parentSome ELF correctness issues, but apparently none enough to placate gdb. (diff)
downloadrust-988695a96cee1eb825435260a1874b8daa0e590a.tar.xz
rust-988695a96cee1eb825435260a1874b8daa0e590a.zip
Added support for task sleeping in the scheduler.
Diffstat (limited to 'src/rt/rust_dom.cpp')
-rw-r--r--src/rt/rust_dom.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/rt/rust_dom.cpp b/src/rt/rust_dom.cpp
index f7b8e97b..1d067560 100644
--- a/src/rt/rust_dom.cpp
+++ b/src/rt/rust_dom.cpp
@@ -330,7 +330,9 @@ rust_dom::schedule_task()
if (running_tasks.length() > 0) {
size_t i = rand(&rctx);
i %= running_tasks.length();
- return (rust_task *)running_tasks[i];
+ if (running_tasks[i]->yield_timer.has_timed_out()) {
+ return (rust_task *)running_tasks[i];
+ }
}
// log(rust_log::DOM|rust_log::TASK, "no schedulable tasks");
return NULL;
@@ -349,8 +351,11 @@ rust_dom::log_state() {
log(rust_log::TASK, "running tasks:");
for (size_t i = 0; i < running_tasks.length(); i++) {
log(rust_log::TASK,
- "\t task: %s @0x%" PRIxPTR,
- running_tasks[i]->name, running_tasks[i]);
+ "\t task: %s @0x%" PRIxPTR
+ " timeout: %d",
+ running_tasks[i]->name,
+ running_tasks[i],
+ running_tasks[i]->yield_timer.get_timeout());
}
}
@@ -396,8 +401,8 @@ rust_dom::start_main_loop()
rust_task *scheduled_task = schedule_task();
// If we cannot schedule a task because all other live tasks
- // are blocked, wait on a condition variable which is signaled
- // if progress is made in other domains.
+ // are blocked, yield and hopefully some progress is made in
+ // other domains.
if (scheduled_task == NULL) {
if (_log.is_tracing(rust_log::TASK)) {