sched: implement user-mode task and thread creation
This commit is contained in:
16
sched/core.c
16
sched/core.c
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user