bump-allocated PID but kheap needs fix to kmalloc more than PAGE_SIZE

This commit is contained in:
2026-02-02 11:05:27 +01:00
parent 4a90de9521
commit 7bb542d901
8 changed files with 96 additions and 31 deletions

View File

@@ -4,32 +4,37 @@
extern struct process_t* processes_list;
extern struct process_t* current_process;
// DEBUG: how many times we did schedule
int scheduled = 0;
void scheduler_init()
{
// Choose first process?
current_process = processes_list;
}
void scheduler_schedule()
struct cpu_status_t* scheduler_schedule(struct cpu_status_t* context)
{
//DEBUG("Scheduler called!");
if (current_process->next != NULL)
{
current_process = current_process->next;
} else
{
current_process = processes_list;
}
scheduled++;
DEBUG("SCHEDULER CALLED: current_process=%p", current_process);
current_process->context = context;
current_process->status = READY;
// debug
/* if (scheduled == 5)
{
DEBUG("enough, halting");
hcf();
} */
for (;;) {
struct process_t* prev_process = current_process;
if (current_process->next != NULL)
{
current_process = current_process->next;
} else
{
current_process = processes_list;
}
if (current_process != NULL && current_process->status == DEAD)
{
process_delete(&prev_process, current_process);
} else
{
current_process->status = RUNNING;
break;
}
}
DEBUG("SCHEDULER CALLED: current_process=%p", current_process);
return current_process->context;
}