Nonblocking mail_receive, fix proc_kill scheduling issues
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m15s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m15s
This commit is contained in:
@@ -273,40 +273,7 @@ static struct proc* proc_find_sched (struct cpu* cpu) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void proc_reaper (struct reschedule_ctx* rctx) {
|
||||
uint64_t fpt, fp, fc;
|
||||
|
||||
struct list_node_link* reaper_list = NULL;
|
||||
|
||||
spin_lock (&proc_tree_lock, &fpt);
|
||||
spin_lock (&thiscpu->lock, &fc);
|
||||
|
||||
struct list_node_link *run_link, *tmp_run_link;
|
||||
list_foreach (thiscpu->proc_run_q, run_link, tmp_run_link) {
|
||||
struct proc* proc = list_entry (run_link, struct proc, cpu_run_q_link);
|
||||
|
||||
if (!proc->dead)
|
||||
continue;
|
||||
|
||||
spin_lock (&proc->lock, &fp);
|
||||
list_remove (thiscpu->proc_run_q, &proc->cpu_run_q_link);
|
||||
rbtree_delete (&proc_tree, &proc->proc_tree_link);
|
||||
list_append (reaper_list, &proc->reaper_list_link);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
}
|
||||
|
||||
spin_unlock (&thiscpu->lock, fc);
|
||||
spin_unlock (&proc_tree_lock, fpt);
|
||||
|
||||
struct list_node_link *rlink, *tmp_rlink;
|
||||
list_foreach (reaper_list, rlink, tmp_rlink) {
|
||||
struct proc* proc = list_entry (rlink, struct proc, reaper_list_link);
|
||||
list_remove (reaper_list, &proc->reaper_list_link);
|
||||
proc_cleanup (proc, rctx);
|
||||
}
|
||||
}
|
||||
|
||||
void proc_sched (void) {
|
||||
void proc_sched (bool user) {
|
||||
struct proc* next = NULL;
|
||||
struct cpu* cpu = thiscpu;
|
||||
uint64_t fc;
|
||||
@@ -319,7 +286,10 @@ retry:
|
||||
if (next) {
|
||||
cpu->proc_current = next;
|
||||
|
||||
do_sched (next, &cpu->lock, fc);
|
||||
if (user)
|
||||
do_sched (next, &cpu->lock, fc);
|
||||
else
|
||||
spin_unlock (&cpu->lock, fc);
|
||||
} else {
|
||||
cpu->proc_current = NULL;
|
||||
spin_unlock (&cpu->lock, fc);
|
||||
@@ -343,22 +313,25 @@ void proc_kill (struct proc* proc, struct reschedule_ctx* rctx) {
|
||||
struct cpu* cpu = proc->cpu;
|
||||
spin_unlock (&proc->lock, fp);
|
||||
|
||||
spin_lock (&proc_tree_lock, &fpt);
|
||||
spin_lock (&cpu->lock, &fc);
|
||||
spin_lock (&proc->lock, &fp);
|
||||
|
||||
proc->cpu = NULL;
|
||||
proc->dead = true;
|
||||
|
||||
list_remove (cpu->proc_run_q, &proc->cpu_run_q_link);
|
||||
cpu->proc_run_q_count--;
|
||||
if (cpu->proc_current == proc)
|
||||
cpu->proc_current = NULL;
|
||||
|
||||
proc->dead = true;
|
||||
rbtree_delete (&proc_tree, &proc->proc_tree_link);
|
||||
|
||||
spin_unlock (&proc->lock, fp);
|
||||
spin_unlock (&cpu->lock, fc);
|
||||
|
||||
rctx_insert_cpu (rctx, cpu);
|
||||
spin_unlock (&proc_tree_lock, fpt);
|
||||
|
||||
DEBUG ("killed PID %d\n", proc->pid);
|
||||
proc_cleanup (proc, rctx);
|
||||
rctx_insert_cpu (rctx, cpu);
|
||||
}
|
||||
|
||||
void proc_wait_for (struct proc* proc, struct reschedule_ctx* rctx, struct proc* wait_proc) {
|
||||
@@ -368,12 +341,6 @@ void proc_wait_for (struct proc* proc, struct reschedule_ctx* rctx, struct proc*
|
||||
static void proc_irq_sched (void* arg, void* regs, bool user, struct reschedule_ctx* rctx) {
|
||||
(void)arg, (void)regs, (void)rctx;
|
||||
|
||||
proc_reaper (rctx);
|
||||
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
|
||||
rctx_insert_cpu (rctx, thiscpu);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user