summaryrefslogtreecommitdiff
path: root/kern/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'kern/thread.c')
-rw-r--r--kern/thread.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/kern/thread.c b/kern/thread.c
index e6875586..7ce22fb7 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -551,7 +551,7 @@ thread_runq_get_next(struct thread_runq *runq)
thread = thread_sched_ops[i].get_next(runq);
if (thread != NULL) {
- runq->current = thread;
+ atomic_store(&runq->current, thread, ATOMIC_RELAXED);
return thread;
}
}
@@ -571,7 +571,7 @@ thread_runq_set_next(struct thread_runq *runq, struct thread *thread)
ops->set_next(runq, thread);
}
- runq->current = thread;
+ atomic_store(&runq->current, thread, ATOMIC_RELAXED);
}
static void
@@ -2736,3 +2736,14 @@ thread_key_create(unsigned int *keyp, thread_dtor_fn_t dtor)
thread_dtors[key] = dtor;
*keyp = key;
}
+
+bool
+thread_is_running(const struct thread *thread)
+{
+ const struct thread_runq *runq;
+
+ runq = thread->runq;
+
+ return (runq != NULL)
+ && (atomic_load(&runq->current, ATOMIC_RELAXED) == thread);
+}