wip: context switch when switching to another process
This commit is contained in:
@ -37,6 +37,8 @@ void scheduler(uint32_t *esp)
|
||||
kpanic("No existing threads \n");
|
||||
if (current_tcb)
|
||||
current_tcb->esp = esp;
|
||||
if (thread_to_switch->process != current_pcb)
|
||||
switch_process(thread_to_switch->process);
|
||||
current_tcb = thread_to_switch;
|
||||
switch_thread(thread_to_switch->esp);
|
||||
}
|
||||
|
||||
16
src/multitasking/switch_process.s
Normal file
16
src/multitasking/switch_process.s
Normal file
@ -0,0 +1,16 @@
|
||||
.intel_syntax noprefix
|
||||
.extern current_pcb
|
||||
|
||||
.section .text
|
||||
.global switch_process
|
||||
|
||||
switch_process:
|
||||
// change current_pcb global
|
||||
mov eax, [esp + 4]
|
||||
mov [current_pcb], eax
|
||||
|
||||
// reload cr3 with the new heap
|
||||
mov edx, [eax + 0]
|
||||
mov cr3, edx
|
||||
|
||||
ret
|
||||
Reference in New Issue
Block a user