Simplified RR, cleanup stream function params

This commit is contained in:
2026-03-18 23:18:06 +01:00
parent 4c26fcfc11
commit 0f320c8f07
6 changed files with 29 additions and 45 deletions

View File

@@ -49,6 +49,7 @@ struct proc* kproc_create (void) {
kproc->lock = SPIN_LOCK_INIT;
kproc->flags |= PROC_KPROC;
kproc->state = PROC_READY;
kproc->pid = proc_alloc_pid ();
kproc->procgroup = procgroup_create ();
@@ -58,7 +59,7 @@ struct proc* kproc_create (void) {
struct reschedule_ctx rctx;
memset (&rctx, 0, sizeof (rctx));
proc_register (kproc, NULL, &rctx);
proc_register (kproc, thiscpu, &rctx);
return kproc;
}
@@ -228,24 +229,19 @@ void proc_register_partial (struct proc* proc) {
static struct proc* proc_find_sched (struct cpu* cpu) {
uint64_t fp;
struct list_node_link *current, *start;
if (!cpu->proc_run_q)
return NULL;
struct list_node_link *current, *start;
if (cpu->proc_current && cpu->proc_current->cpu_run_q_link.next)
current = cpu->proc_current->cpu_run_q_link.next;
else
current = cpu->proc_run_q;
if (!current)
current = cpu->proc_run_q;
start = current;
bool wrap = false;
while (current) {
do {
struct proc* proc = list_entry (current, struct proc, cpu_run_q_link);
spin_lock (&proc->lock, &fp);
@@ -261,14 +257,9 @@ static struct proc* proc_find_sched (struct cpu* cpu) {
current = current->next;
if (!current && !wrap) {
if (!current)
current = cpu->proc_run_q;
wrap = true;
}
if (wrap && current == start)
break;
}
} while (current != start);
return NULL;
}