summaryrefslogtreecommitdiff
path: root/kern/thread.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-02-12 21:03:39 +0100
committerRichard Braun <rbraun@sceen.net>2018-02-12 21:03:59 +0100
commitb9cecdff97e290dc919de6bd318e6d6be5ee6d2d (patch)
treec63a3d46864508971c0198b22c28bb54f89bf14b /kern/thread.c
parentc04a26ee892d440979a84b891d6fac14cd4686f1 (diff)
kern/thread: minor changes
Make thread_runq_schedule() slightly more resilient by setting the next thread pointer to NULL after the context switch.
Diffstat (limited to 'kern/thread.c')
-rw-r--r--kern/thread.c11
1 files changed, 7 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);