diff options
author | Richard Braun <rbraun@sceen.net> | 2018-06-25 21:36:35 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2018-06-25 21:36:35 +0200 |
commit | 64d74fe8d76c230e61b17482bb098d7f9729141d (patch) | |
tree | 0c64452235dbd115d0e76c14a6175ff339d8d74f /kern | |
parent | 3e57b6d2133c460af083d240f562f5f040402873 (diff) |
kern/thread: new thread_cpu function
Diffstat (limited to 'kern')
-rw-r--r-- | kern/thread.c | 9 | ||||
-rw-r--r-- | kern/thread.h | 7 |
2 files changed, 16 insertions, 0 deletions
diff --git a/kern/thread.c b/kern/thread.c index 79199a8f..3b6ed3a0 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -2908,6 +2908,15 @@ thread_key_create(unsigned int *keyp, thread_dtor_fn_t dtor) } unsigned int +thread_cpu(const struct thread *thread) +{ + const struct thread_runq *runq; + + runq = atomic_load(&thread->runq, ATOMIC_RELAXED); + return runq->cpu; +} + +unsigned int thread_state(const struct thread *thread) { return atomic_load(&thread->state, ATOMIC_RELAXED); diff --git a/kern/thread.h b/kern/thread.h index cc1a8a2b..38ee29b3 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -713,6 +713,13 @@ thread_get_specific(unsigned int key) } /* + * Return the last CPU on which the thread has been scheduled. + * + * This call isn't synchronized, and the caller may obtain an outdated value. + */ +unsigned int thread_cpu(const struct thread *thread); + +/* * Return the current state of the given thread. * * This call isn't synchronized, and the caller may obtain an outdated value. |