diff options
author | Richard Braun <rbraun@sceen.net> | 2017-06-13 23:26:38 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-06-14 01:09:02 +0200 |
commit | 3350443b4a800a16f4663e0573903633ad82225f (patch) | |
tree | c1a7a23d0c7920fbbc3776d302e33197b3dd3af4 /kern | |
parent | 72ed0dc2f153e7cf1d6e96f86a773bbe490e9e1c (diff) |
x86: improve TCB load and context switch
Diffstat (limited to 'kern')
-rw-r--r-- | kern/thread.c | 10 | ||||
-rw-r--r-- | kern/thread.h | 7 | ||||
-rw-r--r-- | kern/thread_i.h | 4 |
3 files changed, 11 insertions, 10 deletions
diff --git a/kern/thread.c b/kern/thread.c index dd0d709f..8111c252 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -1727,8 +1727,8 @@ thread_ap_bootstrap(void) tcb_set_current(&thread_booters[cpu_id()].tcb); } -static void -thread_main(void) +void +thread_main(void (*fn)(void *), void *arg) { struct thread *thread; @@ -1742,7 +1742,7 @@ thread_main(void) cpu_intr_enable(); thread_preempt_enable(); - thread->fn(thread->arg); + fn(arg); thread_exit(); } @@ -1829,14 +1829,12 @@ thread_init(struct thread *thread, void *stack, thread->task = task; thread->stack = stack; strlcpy(thread->name, attr->name, sizeof(thread->name)); - thread->fn = fn; - thread->arg = arg; if (attr->flags & THREAD_ATTR_DETACHED) { thread->flags |= THREAD_DETACHED; } - error = tcb_init(&thread->tcb, stack, thread_main); + error = tcb_init(&thread->tcb, stack, fn, arg); if (error) { goto error_tcb; diff --git a/kern/thread.h b/kern/thread.h index 144735d5..f41daefb 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -171,6 +171,13 @@ void thread_bootstrap(void); void thread_ap_bootstrap(void); /* + * Thread entry point. + * + * Loaded TCBs are expected to call this function with interrupts disabled. + */ +void thread_main(void (*fn)(void *), void *arg); + +/* * Initialize the thread module. */ void thread_setup(void); diff --git a/kern/thread_i.h b/kern/thread_i.h index 6f08c335..9c8d4fdf 100644 --- a/kern/thread_i.h +++ b/kern/thread_i.h @@ -178,10 +178,6 @@ struct thread { struct list task_node; /* (T) */ void *stack; /* (-) */ char name[THREAD_NAME_SIZE]; /* ( ) */ - - /* TODO Move out of the structure and make temporary */ - void (*fn)(void *); - void *arg; } __aligned(CPU_L1_SIZE); #define THREAD_ATTR_DETACHED 0x1 |