diff options
author | Richard Braun <rbraun@sceen.net> | 2012-12-28 19:42:22 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2012-12-28 19:45:37 +0100 |
commit | 3fa27e6bbd937c36ba845ed29b1a9369a8d97c9a (patch) | |
tree | 68fd407f2e74129990c6df7b51d5d740c9de8ef6 /kern/thread.h | |
parent | b841232941239387ca81adaaa64f2887077dabd0 (diff) |
kern/thread: make thread_current migration-safe
This change removes the current thread member from the run queues, and moves
the responsibility of maintaining it to the architecture specific tcb module.
For the x86 architecture, the TCB functions use a per-CPU pointer that can
be read and set in a single instruction, making it interrupt-safe and thus
migration-safe.
Diffstat (limited to 'kern/thread.h')
-rw-r--r-- | kern/thread.h | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/kern/thread.h b/kern/thread.h index c5f2d07d..8e1f961f 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -58,17 +58,6 @@ struct thread { } __aligned(CPU_L1_SIZE); /* - * Per processor run queue. - */ -struct thread_runq { - struct thread *current; - struct thread *idle; - struct list threads; -} __aligned(CPU_L1_SIZE); - -extern struct thread_runq thread_runqs[MAX_CPUS]; - -/* * Early initialization of the thread module. * * This function makes it possible to use migration and preemption control @@ -77,6 +66,11 @@ extern struct thread_runq thread_runqs[MAX_CPUS]; void thread_bootstrap(void); /* + * Early initialization of the TCB on APs. + */ +void thread_ap_bootstrap(void); + +/* * Initialize the thread module. */ void thread_setup(void); @@ -119,16 +113,10 @@ void thread_preempt_schedule(void); */ void thread_tick(void); -static inline struct thread_runq * -thread_runq_local(void) -{ - return &thread_runqs[cpu_id()]; -} - static inline struct thread * thread_current(void) { - return thread_runq_local()->current; + return structof(tcb_current(), struct thread, tcb); } /* |