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/thread.c | |
parent | 72ed0dc2f153e7cf1d6e96f86a773bbe490e9e1c (diff) |
x86: improve TCB load and context switch
Diffstat (limited to 'kern/thread.c')
-rw-r--r-- | kern/thread.c | 10 |
1 files changed, 4 insertions, 6 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; |