summaryrefslogtreecommitdiff
path: root/kern/thread.c
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2012-12-29 17:18:11 +0100
committerRichard Braun <rbraun@sceen.net>2012-12-29 17:18:11 +0100
commit9b00cdf3846b84c3aba24df28c0bdd10d5baf0b5 (patch)
treece483228035c3a304c757dbd108cd39100cec662 /kern/thread.c
parent90dd685f2cbe1aa50ff8684e3b07f27b582771e2 (diff)
kern/thread: handle address space on context switch
Diffstat (limited to 'kern/thread.c')
-rw-r--r--kern/thread.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/kern/thread.c b/kern/thread.c
index e3298261..4c48ef0d 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -29,7 +29,9 @@
#include <kern/task.h>
#include <kern/thread.h>
#include <machine/cpu.h>
+#include <machine/pmap.h>
#include <machine/tcb.h>
+#include <vm/vm_map.h>
/*
* Per processor run queue.
@@ -241,9 +243,21 @@ thread_run(void)
if (thread == NULL)
thread = runq->idle;
+ if (thread->task != kernel_task)
+ pmap_load(thread->task->map->pmap);
+
tcb_load(&thread->tcb);
}
+static inline void
+thread_switch(struct thread *prev, struct thread *next)
+{
+ if ((prev->task != next->task) && (next->task != kernel_task))
+ pmap_load(next->task->map->pmap);
+
+ tcb_switch(&prev->tcb, &next->tcb);
+}
+
void
thread_schedule(void)
{
@@ -271,7 +285,7 @@ thread_schedule(void)
next = runq->idle;
if (prev != next)
- tcb_switch(&prev->tcb, &next->tcb);
+ thread_switch(prev, next);
cpu_intr_restore(flags);
thread_preempt_enable_no_resched();