diff options
author | Neal H. Walfield <neal@gnu.org> | 2009-02-24 03:05:20 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@gnu.org> | 2009-02-24 03:05:20 +0100 |
commit | e3791678aeb77756ee517fbd0af2600ea32033c9 (patch) | |
tree | 7cac9b1db24c10d26d44625fd341ab3093d7c42b | |
parent | 1b9c502bdfb2edda3aef870a8b6e2b378ba2095b (diff) |
If the specified thread is not runnable, not run it.
-rw-r--r-- | viengoos/scheduler.c | 8 | ||||
-rw-r--r-- | viengoos/scheduler.h | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/viengoos/scheduler.c b/viengoos/scheduler.c index 210bdc7..1a50618 100644 --- a/viengoos/scheduler.c +++ b/viengoos/scheduler.c @@ -116,19 +116,23 @@ schedule (struct thread *thread) } } - if (likely (! thread && current_thread)) + if (likely (current_thread) + && (likely (! thread) || thread == current_thread)) /* We don't have to switch and the current thread hasn't exceed its allowance. Keep it on the CPU. */ return; if (thread) - /* The caller specified a thread to run. Use it. */ + /* The caller specified a different thread to run. Use it. */ { assert (thread->state == THREAD_RUNNABLE || thread->state == THREAD_SUSPENDED); if (thread->state == THREAD_RUNNABLE) thread_remove_from_run_queue (thread); + else + /* The specified thread is not runnable. */ + thread = NULL; } if (! thread) diff --git a/viengoos/scheduler.h b/viengoos/scheduler.h index 308927a..7bd1e0e 100644 --- a/viengoos/scheduler.h +++ b/viengoos/scheduler.h @@ -27,7 +27,7 @@ extern struct thread *current_thread; /* Schedule thread THREAD to run next. If thread is NULL, selects a new thread. */ -extern void thread_schedule (struct thread *thread); +extern void schedule (struct thread *thread); extern void thread_make_runnable (struct thread *thread); |