Scheduler returns to IDLE when.. idle.

This commit is contained in:
2026-03-09 09:27:55 +01:00
parent 42c7a55d3f
commit 3f9b78b05e
6 changed files with 20 additions and 17 deletions

View File

@@ -45,7 +45,7 @@ void process_display_list(struct process_t* processes_list)
struct process_t* process_create(char* name, void(*function)(void*), void* arg)
{
/* CLEAR_INTERRUPTS; */
CLEAR_INTERRUPTS;
struct process_t* proc = (struct process_t*)kmalloc(sizeof(struct process_t));
struct cpu_status_t* ctx = (struct cpu_status_t*)kmalloc(sizeof(struct cpu_status_t));
@@ -79,7 +79,7 @@ struct process_t* process_create(char* name, void(*function)(void*), void* arg)
process_add(&processes_list, proc);
/* SET_INTERRUPTS; */
SET_INTERRUPTS;
return proc;
}

View File

@@ -12,6 +12,7 @@
extern struct process_t* processes_list;
extern struct process_t* current_process;
extern struct process_t* idle_proc;
void scheduler_init()
{
@@ -28,9 +29,8 @@ struct cpu_status_t* scheduler_schedule(struct cpu_status_t* context)
if (current_process == NULL)
{
// Wtf happened
current_process = processes_list;
//panic(NULL, "Scheduler called without current process");
// If no more processes, then set IDLE as the current process, that's it.
current_process = idle_proc;
}
current_process->context = context;
@@ -49,15 +49,15 @@ struct cpu_status_t* scheduler_schedule(struct cpu_status_t* 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;
break;
}
}
// Current_process gets wrong context?? (iret_rip points to other stuff than process function; like putpixel() for example)
DEBUG("current_process={pid=%u, name='%s', root_page_table[virt]=%p}", current_process->pid, current_process->name, current_process->root_page_table);
load_cr3(VIRT_TO_PHYS((uint64_t)current_process->root_page_table));