Merge pull request #2842 from Subv/switchable_page_table
Kernel/Memory: Give each process its own page table and allow switching the current page table upon reschedule
This commit is contained in:
commit
813837c5cf
14 changed files with 191 additions and 123 deletions
|
@ -171,6 +171,8 @@ static void SwitchContext(Thread* new_thread) {
|
|||
// Cancel any outstanding wakeup events for this thread
|
||||
CoreTiming::UnscheduleEvent(ThreadWakeupEventType, new_thread->callback_handle);
|
||||
|
||||
auto previous_process = Kernel::g_current_process;
|
||||
|
||||
current_thread = new_thread;
|
||||
|
||||
ready_queue.remove(new_thread->current_priority, new_thread);
|
||||
|
@ -178,8 +180,18 @@ static void SwitchContext(Thread* new_thread) {
|
|||
|
||||
Core::CPU().LoadContext(new_thread->context);
|
||||
Core::CPU().SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress());
|
||||
|
||||
if (previous_process != current_thread->owner_process) {
|
||||
Kernel::g_current_process = current_thread->owner_process;
|
||||
Memory::current_page_table = &Kernel::g_current_process->vm_manager.page_table;
|
||||
// We have switched processes and thus, page tables, clear the instruction cache so we
|
||||
// don't keep stale data from the previous process.
|
||||
Core::CPU().ClearInstructionCache();
|
||||
}
|
||||
} else {
|
||||
current_thread = nullptr;
|
||||
// Note: We do not reset the current process and current page table when idling because
|
||||
// technically we haven't changed processes, our threads are just paused.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue