summaryrefslogtreecommitdiff
path: root/kern/thread.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-07-21 00:54:31 +0200
committerRichard Braun <rbraun@sceen.net>2017-07-21 00:54:54 +0200
commit4c0dcbeb7d363918c9a4a75faf3f1912f580f9c1 (patch)
tree6fdb4a1b80d4aa51bbafda6f930f9f222adc4368 /kern/thread.c
parentadcae3076edee5ed24cb06f4328f88cfa5e8998a (diff)
parent5c2cf8fff7a1d6dc6b88615df5433ddccbbcf51f (diff)
Merge branch 'adaptive_spinning'
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 df32ab4c..8e5b2b52 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -554,7 +554,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;
}
}
@@ -574,7 +574,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
@@ -2852,3 +2852,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);
+}