process_create_user

This commit is contained in:
2026-04-03 18:45:12 +02:00
parent 1fe5eb2d38
commit 437bd0e751
6 changed files with 60 additions and 35 deletions
+13 -11
View File
@@ -9,17 +9,21 @@
#include <mem/paging.h>
#include <stdint.h>
#include <io/serial/serial.h>
#include <arch/gdt.h>
extern struct process* processes_list;
extern struct process* current_process;
extern struct process* idle_proc;
extern struct tss tss;
/*
* scheduler_init - Choose the first process
*/
void scheduler_init()
{
current_process = processes_list;
DEBUG("scheduler starting with: pid=%u, name='%s', context=%p", current_process->pid, current_process->name, current_process->context);
}
/*
@@ -39,13 +43,15 @@ struct cpu_status* scheduler_schedule(struct cpu_status* context)
}
if (current_process == NULL) {
// If no more processes, then set IDLE as the current process, that's it.
current_process = idle_proc;
panic(NULL, "current_process is NULL");
}
if (current_process->context == NULL) {
panic(NULL, "current_process->context is NULL");
}
if (current_process == idle_proc && current_process->next == NULL)
{
return idle_proc->context;
if (current_process->next == NULL) {
return current_process->context;
}
current_process->context = context;
@@ -61,20 +67,16 @@ struct cpu_status* scheduler_schedule(struct cpu_status* context)
if (current_process != NULL && current_process->status == DEAD) {
process_delete(&prev_process, current_process);
current_process = NULL;
return idle_proc->context;
} else {
current_process->status = RUNNING;
/* if (prev_process != current_process) {
DEBUG("Changed from {pid=%u, name=%s} to {pid=%u, name=%s}", prev_process->pid, prev_process->name, current_process->pid, current_process->name);
} */
break;
}
}
//DEBUG("current_process={pid=%u, name='%s', root_page_table[virt]=%p}", current_process->pid, current_process->name, current_process->root_page_table);
tss.rsp0 = (uint64_t)current_process->kernel_stack;
load_cr3(VIRT_TO_PHYS((uint64_t)current_process->root_page_table));
//DEBUG("Loaded process PML4 into CR3");
return current_process->context;
}