wip: context switch when switching to another process

This commit is contained in:
0x35c
2025-11-11 17:31:08 +01:00
parent e4f5a377a3
commit f9832ff151
3 changed files with 20 additions and 1 deletions

View File

@ -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);
}

View 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