diff options
author | Richard Braun <rbraun@sceen.net> | 2017-06-03 14:20:13 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-06-03 14:20:13 +0200 |
commit | 1b902346ce502870329bda19d92d317a21cab56e (patch) | |
tree | 45f7d5702e0320047966a1fdd903917730f25627 | |
parent | 77bb91faa0059b157220ef2e1732bdf89618a375 (diff) |
kern/thread: improve thread_wakeup robustness
-rw-r--r-- | kern/console.c | 4 | ||||
-rw-r--r-- | kern/sref.c | 3 | ||||
-rw-r--r-- | kern/thread.c | 4 | ||||
-rw-r--r-- | kern/thread.h | 3 | ||||
-rw-r--r-- | kern/work.c | 4 |
5 files changed, 9 insertions, 9 deletions
diff --git a/kern/console.c b/kern/console.c index d7104e47..fef4f654 100644 --- a/kern/console.c +++ b/kern/console.c @@ -155,9 +155,7 @@ console_intr(struct console *console, const char *s) s++; } - if ((console->waiter != NULL) && (console->waiter != thread_self())) { - thread_wakeup(console->waiter); - } + thread_wakeup(console->waiter); out: spinlock_unlock(&console->lock); diff --git a/kern/sref.c b/kern/sref.c index 95e697a4..9c2d7761 100644 --- a/kern/sref.c +++ b/kern/sref.c @@ -976,8 +976,7 @@ sref_report_periodic_event(void) cache = sref_cache_get(); - if (!sref_cache_is_registered(cache) - || (cache->manager == thread_self())) { + if (!sref_cache_is_registered(cache)) { return; } diff --git a/kern/thread.c b/kern/thread.c index 17ac10bd..25d81771 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -2452,6 +2452,10 @@ thread_wakeup(struct thread *thread) struct thread_runq *runq; unsigned long flags; + if ((thread == NULL) || (thread == thread_self())) { + return; + } + /* * There is at most one reference on threads that were never dispatched, * in which case there is no need to lock anything. diff --git a/kern/thread.h b/kern/thread.h index e348fe39..144735d5 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -219,7 +219,8 @@ void thread_sleep(struct spinlock *interlock, const void *wchan_addr, /* * Schedule a thread for execution on a processor. * - * No action is performed if the target thread is already in the running state. + * No action is performed if the target thread is NULL, the calling thread, + * or already in the running state. */ void thread_wakeup(struct thread *thread); diff --git a/kern/work.c b/kern/work.c index 738ab8b6..6c0ed626 100644 --- a/kern/work.c +++ b/kern/work.c @@ -259,9 +259,7 @@ work_pool_wakeup_manager(struct work_pool *pool) return; } - if ((pool->manager != NULL) && (pool->manager->thread != thread_self())) { - thread_wakeup(pool->manager->thread); - } + thread_wakeup(pool->manager->thread); } static void |