sched: simplify entry-exit path between processes

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-22 01:09:27 -04:00
commit 11bedfe3a8
7 changed files with 24 additions and 20 deletions

View file

@ -64,20 +64,15 @@ static struct thread *dequeue_thread()
void schedule()
{
struct thread *cur = get_cur_thread();
struct thread *next = dequeue_thread();
if (!next)
return;
struct thread *prev = cur;
if (cur)
sched_add_thread(cur);
struct cpu_local *tls = tls_get();
tls->cur_thread = next;
tls->kernel_rsp = next->kstack_top;
tls->tss.rsp0 = next->kstack_top;
pgd_load(next->proc->pgd);
switch_to(prev, next);
sched_restore_state(next);
}