tasking: fix stack corruption on the scheduler trigger

This commit is contained in:
2025-08-20 20:59:08 +03:00
parent 9fdc551308
commit 92511dbcd7
2 changed files with 6 additions and 1 deletions
+2
View File
@@ -68,6 +68,8 @@ typedef struct Process
l9660_dir* cwd;
void* brk;
uint32_t kstack_top;
} Process;
extern Process* current;
+4 -1
View File
@@ -32,6 +32,9 @@ Process* task_create(uint32_t func, uint32_t user_esp, uint32_t ring, uint32_t*
p->kstack = (char*)((uint32_t)kstack_physical+0xC0000000);
map_page(kstack_physical, p->kstack, PAGE_PRESENT | PAGE_RW);
debug_log("kstack: %X!!!!!!!!!!!!\n", p->kstack);
p->kstack_top = (uint32_t)p->kstack + KSTACKSIZE;
uint8_t* sp = (uint8_t*)(p->kstack + KSTACKSIZE);
sp -= sizeof(TrapFrame);
@@ -146,7 +149,7 @@ void schedule() {
}
if (next && next != current) {
tss.esp0 = next->kesp;
tss.esp0 = next->kstack_top;
switchProcess(next);
}