tasking: add loading of a process' page directory before switching

This commit is contained in:
2025-04-10 21:38:31 +03:00
parent 372b308ec8
commit 65565dd4a6
2 changed files with 12 additions and 5 deletions
+2
View File
@@ -22,6 +22,8 @@ typedef struct Process
uintptr_t* stackPointer; // Stack Pointer
uint32_t flags; // Status/Flags register
struct Process* next; // Pointer to the next task in the list
uint32_t* page_directory;
} Process;
Process* task_create(EntryPoint func, void** args, uint32_t arg_count);
+10 -5
View File
@@ -44,6 +44,8 @@ Process* task_create(EntryPoint func, void** args, uint32_t arg_count)
*(--p->stackPointer) = 0;//esi
*(--p->stackPointer) = 0;//ebx
p->page_directory = kernel_page_directory;
p->next = 0;
if(!queue)
@@ -84,8 +86,11 @@ void schedule()
if(!next)
next = queue;
if(next != current)
{
loadPageDirectory(next->page_directory);
switchProcess(next);
}
}
void idle()
{
@@ -111,15 +116,15 @@ void jump_usermode2(void);
void scheduler_init()
{
jump_usermode2();
//jump_usermode2();
//we create this task two times because in other case it just won't start
//task_create((EntryPoint)&idle, NULL, 0);
//task_create((EntryPoint)&idle, NULL, 0);
task_create((EntryPoint)&idle, NULL, 0);
task_create((EntryPoint)&idle, NULL, 0);
void* args1[] = {(void*)42, (void*)"ebalo"};
//task_create((EntryPoint)&task1, args1, 2);
task_create((EntryPoint)&task1, args1, 2);
void* args2[] = {(void*)69, (void*)420};
//task_create((EntryPoint)&task2, args2, 2);
task_create((EntryPoint)&task2, args2, 2);
}
extern void test_user_function(void);