diff options
-rw-r--r-- | kern/thread.c | 11 | ||||
-rw-r--r-- | kern/thread.h | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/kern/thread.c b/kern/thread.c index f41e5936..20378ffb 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -653,15 +653,18 @@ thread_runq_schedule(struct thread_runq *runq) * The thread is dispatched on a processor once again. * * Keep in mind the system state may have changed a lot since this - * function was called. In particular, the next thread may have been - * destroyed, and must not be referenced any more. + * function was called. In particular : + * - The next thread may have been destroyed, and must not be + * referenced any more. + * - The current thread may have been migrated to another processor. */ barrier(); - - /* The thread might have been moved to another processor */ + next = NULL; runq = thread_runq_local(); thread_runq_schedule_prepare(prev); + } else { + next = NULL; } assert(prev->preempt_level == THREAD_SUSPEND_PREEMPT_LEVEL); diff --git a/kern/thread.h b/kern/thread.h index 8084c114..58322bda 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -228,6 +228,8 @@ int thread_timedsleep(struct spinlock *interlock, const void *wchan_addr, * * If the target thread is NULL, the calling thread, or already in the * running state, no action is performed and ERROR_INVAL is returned. + * + * TODO Describe memory ordering with regard to thread_sleep(). */ int thread_wakeup(struct thread *thread); @@ -249,6 +251,8 @@ noreturn void thread_run_scheduler(void); * This call does nothing if preemption is disabled, or the scheduler * determines the caller should continue to run (e.g. it's currently the only * runnable thread). + * + * Implies a full memory barrier if a context switch occurred. */ void thread_yield(void); |