diff options
author | Richard Braun <rbraun@sceen.net> | 2012-12-29 16:54:24 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2012-12-29 16:54:24 +0100 |
commit | 90dd685f2cbe1aa50ff8684e3b07f27b582771e2 (patch) | |
tree | 0b03b0dab420f8b633a64fbe04c7d00185ddef9c /kern/thread.c | |
parent | 1390e1961c26f4c305414a29e08948fd9c83e378 (diff) |
kern/thread: fix thread initialization
Threads must be initialized in a way that matches the expected state of a non
running thread. In other words, preemption (in addition to interrupts) must be
disabled. Also, set the migration counter.
Diffstat (limited to 'kern/thread.c')
-rw-r--r-- | kern/thread.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/kern/thread.c b/kern/thread.c index fa86a2ab..e3298261 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -127,9 +127,11 @@ thread_main(void) struct thread *thread; assert(!cpu_intr_enabled()); + assert(!thread_preempt_enabled()); thread = thread_current(); cpu_intr_enable(); + thread_preempt_enable(); thread->fn(thread->arg); @@ -148,7 +150,8 @@ thread_init(struct thread *thread, struct task *task, void *stack, name = task->name; thread->flags = 0; - thread->preempt = 0; + thread->pinned = 0; + thread->preempt = 1; thread->task = task; thread->stack = stack; strlcpy(thread->name, name, sizeof(thread->name)); |