sched: implement user-mode task and thread creation

This commit is contained in:
2026-02-08 13:11:17 +00:00
parent d2f303680d
commit ee82097017
4 changed files with 129 additions and 9 deletions

View File

@@ -72,11 +72,21 @@ static void expire_timers(struct cpu_data *cpu)
void context_switch(struct thread *old, struct thread *new)
{
if (old->tr_parent->t_pmap != new->tr_parent->t_pmap) {
pmap_switch(new->tr_parent->t_pmap);
struct ml_cpu_block *this_cpu = ml_this_cpu();
old->tr_cpu_kernel_sp = ml_cpu_block_get_kstack(this_cpu);
old->tr_cpu_user_sp = ml_cpu_block_get_ustack(this_cpu);
pmap_t old_pmap = old->tr_parent->t_pmap;
pmap_t new_pmap = new->tr_parent->t_pmap;
if (old_pmap != new_pmap) {
pmap_switch(new_pmap);
}
switch_to(old, new);
ml_cpu_block_set_kstack(this_cpu, new->tr_cpu_kernel_sp);
ml_cpu_block_set_ustack(this_cpu, new->tr_cpu_user_sp);
ml_thread_switch(old, new);
}
void __schedule(enum sched_mode mode)